A password I was given to access an institutional database contains
the character '+',
With that password, I'm unable to use sqlalchemy to create a
connection to either postgres or mysql.
I can connect to either db engine via the command line and using
python, django, php, no problem.
But sqlalchemy trips up.
After trying everything else, I changed the password to eliminate the
'+' and the problem disappeared.
Here's a minimal script which demonstrates the problem:
#!/usr/bin/env python
import sys
from sqlalchemy import create_engine, engine
from sqlalchemy.orm import *
import psycopg2
db_user='akea013'
db_pass="1234+ab"
db_host='127.0.0.1'
db_name='akea013'
db_engine='postgres'
db_uri = "%s://%s:%...@%s/%s" %
(db_engine,db_user,db_pass,db_host,db_name)
engine=create_engine(db_uri, echo=True, module=psycopg2)
connection=engine.connect()
result=engine.execute( "select version()")
print result
connection.close()
This produces
Traceback (most recent call last):
File "bootstrap.py", line 15, in <module>
connection=engine.connect()
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/engine/base.py", line 1213, in connect
return self.Connection(self, **kwargs)
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/engine/base.py", line 528, in __init__
self.__connection = connection or engine.raw_connection()
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/engine/base.py", line 1268, in raw_connection
return self.pool.unique_connection()
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/pool.py", line 119, in unique_connection
return _ConnectionFairy(self).checkout()
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/pool.py", line 304, in __init__
rec = self._connection_record = pool.get()
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/pool.py", line 161, in get
return self.do_get()
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/pool.py", line 639, in do_get
con = self.create_connection()
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/pool.py", line 122, in create_connection
return _ConnectionRecord(self)
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/pool.py", line 198, in __init__
self.connection = self.__connect()
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/pool.py", line 261, in __connect
connection = self.__pool._creator()
File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.5.0rc5dev_r5477-
py2.5.egg/sqlalchemy/engine/strategies.py", line 80, in connect
raise exc.DBAPIError.instance(None, None, e)
sqlalchemy.exc.OperationalError: (OperationalError) missing "=" after
"ab" in connection info string
None None
and changing the password to 1234abab I get output
2008-12-15 22:15:30,893 INFO sqlalchemy.engine.base.Engine.0x...2aec
select version()
2008-12-15 22:15:30,894 INFO sqlalchemy.engine.base.Engine.0x...2aec
{}
<sqlalchemy.engine.base.ResultProxy object at 0x9e4488c>
Anita
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---