[Zope3-Users] exploring Zalchemy
catonano
adriano at euma.com
Sun Nov 5 19:09:34 EST 2006
Hello people, hello Jurgen,
last time I wrote, I was at the point that aTable =
sqlalchemy.Table('aTable', z3c.zalchemy.metadata, autoload=True)
doesn't work. I also promised that I would have seen if I could help
with that; Sorry I still can't help.
I would love to succeed in zopezing my MySql database, before anything else.
So I tried to use the example in the zalchemy readme file as it is.
It doesn't work either !
Please help me !
The work session follows.
PyCrust 0.9.5 - The Flakiest Python Shell
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlalchemy
>>> import z3c.zalchemy
>>> from z3c.zalchemy.datamanager import AlchemyEngineUtility
>>> engineUtility =
AlchemyEngineUtility('tender','mysql:///root:speranza@localhost/tender',echo=False)
>>> aTable = sqlalchemy.Table('zalch',
... z3c.zalchemy.metadata,
... sqlalchemy.Column('id', sqlalchemy.Integer,
... sqlalchemy.Sequence('atable_id'), primary_key=True),
... sqlalchemy.Column('value', sqlalchemy.Integer),
... redefine=True)
>>> class A(object):
... pass
...
>>> sqlalchemy.mapper(A, aTable) is not None
True
>>> from zope.component import provideUtility
>>> provideUtility(engineUtility)
>>> z3c.zalchemy.createTable('zalch')
>>> import transaction
>>> txn = transaction.begin()
>>> session = z3c.zalchemy.getSession
>>> session()
[2006-11-05 14:53:19,500] [pool] : Error on connect(): (Connection
failed) (OperationalError) (1045, "Access denied for user
'ODBC'@'localhost' (using password: NO)")
<sqlalchemy.orm.session.Session object at 0x0200D990>
>>>
It tries to connect to MySql with ODBC at localhost usng password: no
But the engineUtility I created had a completely different URL !
Maybe I wrote the url incorrectly ?
Also a simpler url gives the same url.
Look at this
Py 0.9.5
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import sqlalchemy
import z3c.zalchemy
from z3c.zalchemy.datamanager import AlchemyEngineUtility
engineUtility = AlchemyEngineUtility('tender', 'mysql:///root@localhost')
eng = engineUtility.getEngine()
eng.connect()
[2006-11-06 01:04:57,983] [pool] : Error on connect(): (Connection
failed) (OperationalError) (1045, "Access denied for user
'ODBC'@'localhost' (using password: NO)")
Traceback (most recent call last):
File "<input>", line 1, in ?
File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 477, in connect
File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 179,
in __init__
File "build\bdist.win32\egg\sqlalchemy\engine\base.py", line 500,
in raw_connection
File "build\bdist.win32\egg\sqlalchemy\engine\default.py", line
42, in get_connection
File "build\bdist.win32\egg\sqlalchemy\pool.py", line 95, in connect
File "build\bdist.win32\egg\sqlalchemy\pool.py", line 172, in __init__
File "build\bdist.win32\egg\sqlalchemy\pool.py", line 108, in get
File "build\bdist.win32\egg\sqlalchemy\pool.py", line 294, in do_get
File "build\bdist.win32\egg\sqlalchemy\pool.py", line 91, in
create_connection
File "build\bdist.win32\egg\sqlalchemy\pool.py", line 131, in __init__
File "build\bdist.win32\egg\sqlalchemy\pool.py", line 155, in __connect
File "build\bdist.win32\egg\sqlalchemy\engine\default.py", line
33, in connect
DBAPIError: (Connection failed) (OperationalError) (1045, "Access
denied for user 'ODBC'@'localhost' (using password: NO)")
What's wrong with these sessions ?
Thanks so much for any hint
Bye
Catonano
More information about the Zope3-users
mailing list