[SQLObject] createTable returns NoneType error
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Martin d'A. <Mar...@s2...> - 2004-11-16 02:05:39
|
Hi, I have this code where I want to pre-define classes for the tables, and connect them at run time to the database, but it does not work. Here is the code: #!/usr/bin/env python from sqlobject import * class Person(SQLObject): # Connection always defined at runtime name = StringCol(length=255,default=None) def main(db_name): conn = connectionForURI('mysql://user:passwd@server/'+db_name) trans = conn.transaction Person.createTable(trans) if __name__ == '__main__': main('test') % ./simple.py Traceback (most recent call last): File "./simple.py", line 15, in ? main('yo') File "./simple.py", line 12, in main Person.createTable(trans) File "/usr/local/lib/python2.3/site-packages/sqlobject/main.py", line 973, in createTable if ifNotExists and cls._connection.tableExists(cls._table): AttributeError: 'NoneType' object has no attribute 'tableExists' I am sure I am making a mistake... can someone help please? Thanks, Martin |