Thread: [SQLObject] q-magic + multiple connections
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Octav C. <och...@gm...> - 2010-10-13 21:28:30
|
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 |
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 > > |
From: Oleg B. <ph...@ph...> - 2010-10-14 08:27:51
|
Hello! On Wed, Oct 13, 2010 at 04:48:44PM -0700, Octav Chipara wrote: > This also fails to work with selectby as shown in the example below. It > looks like IntCols can be handled correctly but StringCol cannot. > > > 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 You stumbled over exactly the same problem that was discussed a day or two ago - sometimes validators (especially validators for StringCol) need to know the current connection (StringCol's validator needs to know charset/encoding). Please test the patch that I sent and report back if it helps. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Octav C. <och...@gm...> - 2010-10-14 08:47:31
|
Oleg, Unfortunately, I could not locate the patch file. Could you please send it to me and I will apply it and test it? Are the changes already in svn? Thanks, -- Octav On Thu, Oct 14, 2010 at 1:27 AM, Oleg Broytman <ph...@ph...> wrote: > Hello! > > On Wed, Oct 13, 2010 at 04:48:44PM -0700, Octav Chipara wrote: > > This also fails to work with selectby as shown in the example below. It > > looks like IntCols can be handled correctly but StringCol cannot. > > > > > 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 > > You stumbled over exactly the same problem that was discussed a day or > two ago - sometimes validators (especially validators for StringCol) need > to know the current connection (StringCol's validator needs to know > charset/encoding). Please test the patch that I sent and report back if it > helps. > > Oleg. > -- > Oleg Broytman http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today. > http://p.sf.net/sfu/beautyoftheweb > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Oleg B. <ph...@ph...> - 2010-10-14 08:56:46
|
On Thu, Oct 14, 2010 at 01:47:05AM -0700, Octav Chipara wrote: > Unfortunately, I could not locate the patch file. Could you please send it > to me and I will apply it and test it? Sent by private email. > Are the changes already in svn? Not yet. I was going to test it thoroughly today but now I will wait until your report. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Octav C. <och...@gm...> - 2010-10-14 09:05:05
|
Hi Oleg, I applied the patch to my sqlobject version and now it passes the test program I sent earlier. Thank you for your help. -- Octav On Thu, Oct 14, 2010 at 1:56 AM, Oleg Broytman <ph...@ph...> wrote: > On Thu, Oct 14, 2010 at 01:47:05AM -0700, Octav Chipara wrote: > > Unfortunately, I could not locate the patch file. Could you please send > it > > to me and I will apply it and test it? > > Sent by private email. > > > Are the changes already in svn? > > Not yet. I was going to test it thoroughly today but now I will wait > until your report. > > Oleg. > -- > Oleg Broytman http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today. > http://p.sf.net/sfu/beautyoftheweb > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Oleg B. <ph...@ph...> - 2010-10-14 09:08:16
|
On Thu, Oct 14, 2010 at 02:04:39AM -0700, Octav Chipara wrote: > I applied the patch to my sqlobject version and now it passes the test > program I sent earlier. Thank you for your help. Thank you for the report! Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |