On Tue, Jul 08, 2008 at 06:10:03PM -0700, Ray Van Dolson wrote: > Hi all, new to SQLObject, but already really enjoying it.
Welcome! > import sys, os > from sqlobject import * > > class Owners(SQLObject): > class sqlmeta: > table = 'Owners' > fromDatabase = True > > def main(): > conn = connectionForURI("mysql://virtual:[EMAIL > PROTECTED]/virtual?debug=1&debugOutput=1") > sqlhub.processConnection = conn > > o = Owners.get(7) > print o > > if __name__ == '__main__': > main() > > However, this results in the following traceback: > > Traceback (most recent call last): > File "./test3.py", line 6, in ? > class Owners(SQLObject): > File "/usr/lib/python2.4/site-packages/sqlobject/declarative.py", line > 121, in __new__ > cls.__classinit__(cls, new_attrs) > File "/usr/lib/python2.4/site-packages/sqlobject/main.py", line 784, in > __classinit__ > cls.sqlmeta.addColumnsFromDatabase() > File "/usr/lib/python2.4/site-packages/sqlobject/main.py", line 441, in > addColumnsFromDatabase > conn = connection or soClass._connection > File "/usr/lib/python2.4/site-packages/sqlobject/dbconnection.py", line > 973, in __get__ > return self.getConnection() > File "/usr/lib/python2.4/site-packages/sqlobject/dbconnection.py", line > 985, in getConnection > raise AttributeError( > AttributeError: No connection has been defined for this thread or process SQLObject pulls the scheme from the DB at the class creation time, so a connection must be defined before the class. Oleg. -- Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss