Re: [SQLObject] q-magic + multiple connections
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Octav C. <och...@gm...> - 2010-10-13 23:49:10
|
Hi, This also fails to work with selectby as shown in the example below. It looks like IntCols can be handled correctly but StringCol cannot. from sqlobject.inheritance import InheritableSQLObject from sqlobject import StringCol, IntCol, connectionForURI class A(InheritableSQLObject): str_id = StringCol(notNone = True) int_id = IntCol(notNone = True) class B(A): foo = StringCol() sql_con1 = connectionForURI('sqlite:///Users/ochipara/Working/workspace/wiisardpy/provider/conn-1.db') sql_con2 = connectionForURI('sqlite:///Users/ochipara/Working/workspace/wiisardpy/provider/conn-2.db') A.createTable(ifNotExists = True, connection = sql_con1) A.createTable(ifNotExists = True, connection = sql_con2) B.createTable(ifNotExists = True, connection = sql_con1) B.createTable(ifNotExists = True, connection = sql_con2) B(int_id = 1, str_id = '1', foo = 'bar', connection = sql_con1) B(int_id = 1, str_id = '1', foo = 'bar', connection = sql_con2) # objects are created correctly in both dbs # this line works B.selectBy(int_id = 1, connection= sql_con1) # this like throws exception # B.selectBy(str_id = '1', connection= sql_con1) # File "/Library/Python/2.6/site-packages/SQLObject-0.14.0-py2.6.egg/sqlobject/inheritance/__init__.py", line 499, in selectBy # % (cls.__name__, name)) #AttributeError: 'B' instance has no attribute 'str_id' B.selectBy(str_id = '1', connection= sql_con1) On Wed, Oct 13, 2010 at 2:28 PM, Octav Chipara <och...@gm...> wrote: > > Hi, > > I'm trying to use the "q-magic" and multiple connections to run a query > such as the following: > > Person.select(Person.q.object_id =="con1", connection = sql_con1) > > However, I'm getting the following exception: > > File > "/Users/ochipara/Working/workspace/wiisardpy/provider/junk/test_multipleconnections.py", > line 29, in <module> > print Person.select(Person.q.object_id =="con1", connection= sql_con1) > File > "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/sqlbuilder.py", > line 346, in __eq__ > other = self._from_python(other) > File > "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/sqlbuilder.py", > line 341, in _from_python > value = column.from_python(value, SQLObjectState(self.soClass)) > File > "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/col.py", > line 501, in to_python > connection = state.soObject._connection > File > "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/dbconnection.py", > line 837, in __get__ > return self.getConnection() > File > "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/dbconnection.py", > line 850, in getConnection > "No connection has been defined for this thread " > AttributeError: No connection has been defined for this thread or process > Exception AttributeError: "'NoneType' object has no attribute 'print_exc'" > in <function _removeReceiver at 0x1004e3398> ignored > > > Is there a way to use the q-magic over multiple connections? > > Thanks, > -- Octav > > |