[SQLObject] very newbie: how to start with SQLObject ?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Stef M. <ste...@gm...> - 2009-02-02 20:55:38
|
hello, until now I used SQL directly, but to create functional code, independent of the chosen database, I'm looking for something different. So I found SQLObject and SQLAlchemy, and can't find out from the discussions which is better suited for my purposes, so I decided to give both a try. I started with SQLObject because in general it's decribed as "easier". So I started here: http://www.sqlobject.org/SQLObject.html The first problem is that the first example already contains an error ( at least that's what I guess) connection_string = 'sqlite:' + db_filename I think there's a slash missing ? Now the second problem is, that I want to start with an existing database: So this is my code: from sqlobject import * class Test_Create2 ( SQLObject ) : class sqlmeta : print 'piep' fromDatabase = True if __name__ == '__main__': DataBase_Name = 'D:/Data_Python_25/support/test_vl.db' sqlhub.processConnection = connectionForURI ( 'sqlite:/' + DataBase_Name ) Test_Create2.createTable () and this the error I get: Traceback (most recent call last): File "D:\Data_Python_25\support\db_support.py", line 507, in <module> class Test_Create2 ( SQLObject ) : File "p:\python\lib\site-packages\SQLObject-0.10.4-py2.5.egg\sqlobject\declarative.py", line 92, in __new__ cls.__classinit__(cls, new_attrs) File "p:\python\lib\site-packages\SQLObject-0.10.4-py2.5.egg\sqlobject\main.py", line 791, in __classinit__ cls.sqlmeta.addColumnsFromDatabase() File "p:\python\lib\site-packages\SQLObject-0.10.4-py2.5.egg\sqlobject\main.py", line 446, in addColumnsFromDatabase conn = connection or soClass._connection File "p:\python\lib\site-packages\SQLObject-0.10.4-py2.5.egg\sqlobject\dbconnection.py", line 829, in __get__ return self.getConnection() File "p:\python\lib\site-packages\SQLObject-0.10.4-py2.5.egg\sqlobject\dbconnection.py", line 842, in getConnection "No connection has been defined for this thread " AttributeError: No connection has been defined for this thread or process thanks, Stef Mientki |