zzzeek / sqla_issue_test

1 stars 0 forks source link

MySQLdb expects integer for port argument #209

Closed zzzeek closed 6 years ago

zzzeek commented 18 years ago

Originally reported by: Anonymous


Running mysql on port 8989, the following script (slightly modified from the tutorial) fails:

from sqlalchemy import *
db = create_engine('mysql://user:password@hostname:8989/test')
db.echo = True  # Try changing this to True and see what happens
metadata = BoundMetaData(db)
users = Table('users', metadata,
    Column('user_id', Integer, primary_key=True),
    Column('name', String(40)),
    Column('age', Integer),
    Column('password', String),
)
users.create()

with:

Traceback (most recent call last): File "testSqlAlchemy.py", line 15, in ? users.create() File "build/bdist.linux-i686/egg/sqlalchemy/schema.py", line 230, in create File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 395, in create File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 415, in _run_visitor File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 475, in contextual_connect File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 177, in init File "build/bdist.linux-i686/egg/sqlalchemy/engine/base.py", line 493, in raw_connection File "build/bdist.linux-i686/egg/sqlalchemy/engine/default.py", line 34, in get_connection File "build/bdist.linux-i686/egg/sqlalchemy/pool.py", line 84, in connect File "build/bdist.linux-i686/egg/sqlalchemy/pool.py", line 130, in init File "build/bdist.linux-i686/egg/sqlalchemy/pool.py", line 102, in get File "build/bdist.linux-i686/egg/sqlalchemy/pool.py", line 229, in do_get File "build/bdist.linux-i686/egg/sqlalchemy/engine/default.py", line 27, in File "/home/gendev/sciflo/lib/python2.4/site-packages/MySQLdb/init.py", line 66, in Connect return Connection(*args, *kwargs) File "/home/gendev/sciflo/lib/python2.4/site-packages/MySQLdb/connections.py", line 134, in init super(Connection, self).init(args, **kwargs2) TypeError: an integer is required

Adding the following code to line 149 of databases/mysql.py

if opts.has_key('port'): opts['port']('port') = int(opts['port']('port'))

Now script works:

$ python testSqlAlchemy.py 10:42:41,459 engine: CREATE TABLE users( user_id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, name VARCHAR(40), age INTEGER, password TEXT )

10:42:41,460 engine: None 10:42:41,478 engine: COMMIT


zzzeek commented 10 years ago

Original comment by Michael Bayer (Bitbucket: zzzeek, GitHub: zzzeek):


Removing milestone: 0.4.0 (automated comment)

zzzeek commented 17 years ago

Original comment by Michael Bayer (Bitbucket: zzzeek, GitHub: zzzeek):


Milestone next micropoint release deleted

zzzeek commented 18 years ago

Original comment by Michael Bayer (Bitbucket: zzzeek, GitHub: zzzeek):


changeset:1628

zzzeek commented 18 years ago

Original comment by Michael Bayer (Bitbucket: zzzeek, GitHub: zzzeek):


will commit the fix soon