sqlobject-discuss Mailing List for SQLObject (Page 34)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
2003 |
Jan
|
Feb
(2) |
Mar
(43) |
Apr
(204) |
May
(208) |
Jun
(102) |
Jul
(113) |
Aug
(63) |
Sep
(88) |
Oct
(85) |
Nov
(95) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(38) |
Feb
(93) |
Mar
(125) |
Apr
(89) |
May
(66) |
Jun
(65) |
Jul
(53) |
Aug
(65) |
Sep
(79) |
Oct
(60) |
Nov
(171) |
Dec
(176) |
2005 |
Jan
(264) |
Feb
(260) |
Mar
(145) |
Apr
(153) |
May
(192) |
Jun
(166) |
Jul
(265) |
Aug
(340) |
Sep
(300) |
Oct
(469) |
Nov
(316) |
Dec
(235) |
2006 |
Jan
(236) |
Feb
(156) |
Mar
(229) |
Apr
(221) |
May
(257) |
Jun
(161) |
Jul
(97) |
Aug
(169) |
Sep
(159) |
Oct
(400) |
Nov
(136) |
Dec
(134) |
2007 |
Jan
(152) |
Feb
(101) |
Mar
(115) |
Apr
(120) |
May
(129) |
Jun
(82) |
Jul
(118) |
Aug
(82) |
Sep
(30) |
Oct
(101) |
Nov
(137) |
Dec
(53) |
2008 |
Jan
(83) |
Feb
(139) |
Mar
(55) |
Apr
(69) |
May
(82) |
Jun
(31) |
Jul
(66) |
Aug
(30) |
Sep
(21) |
Oct
(37) |
Nov
(41) |
Dec
(65) |
2009 |
Jan
(69) |
Feb
(46) |
Mar
(22) |
Apr
(20) |
May
(39) |
Jun
(30) |
Jul
(36) |
Aug
(58) |
Sep
(38) |
Oct
(20) |
Nov
(10) |
Dec
(11) |
2010 |
Jan
(24) |
Feb
(63) |
Mar
(22) |
Apr
(72) |
May
(8) |
Jun
(13) |
Jul
(35) |
Aug
(23) |
Sep
(12) |
Oct
(26) |
Nov
(11) |
Dec
(30) |
2011 |
Jan
(15) |
Feb
(44) |
Mar
(36) |
Apr
(26) |
May
(27) |
Jun
(10) |
Jul
(28) |
Aug
(12) |
Sep
|
Oct
|
Nov
(17) |
Dec
(16) |
2012 |
Jan
(12) |
Feb
(31) |
Mar
(23) |
Apr
(14) |
May
(10) |
Jun
(26) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(6) |
2013 |
Jan
(4) |
Feb
(5) |
Mar
|
Apr
(4) |
May
(13) |
Jun
(7) |
Jul
(5) |
Aug
(15) |
Sep
(25) |
Oct
(18) |
Nov
(7) |
Dec
(3) |
2014 |
Jan
(1) |
Feb
(5) |
Mar
|
Apr
(3) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(5) |
Sep
|
Oct
(11) |
Nov
|
Dec
(62) |
2015 |
Jan
(8) |
Feb
(3) |
Mar
(15) |
Apr
|
May
|
Jun
(6) |
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
(19) |
2016 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
(4) |
May
(3) |
Jun
(7) |
Jul
(14) |
Aug
(13) |
Sep
(6) |
Oct
(2) |
Nov
(3) |
Dec
|
2017 |
Jan
(6) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(4) |
Nov
(3) |
Dec
|
2018 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
(1) |
Mar
|
Apr
(44) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2021 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2025 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
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-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: 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: Oleg B. <ph...@ph...> - 2010-10-12 15:38:30
|
On Tue, Oct 12, 2010 at 05:17:53PM +0200, Georges Schutz wrote: > --> So for me the patch is OK. Thank you for the report! > >> conn = sobj.connectionForURI('sqlite:/:memory:') > >> ^^^^^^^^ > >> Person.createTable(ifNotExists=True, connection=conn) > > ^^^^^^^^^^^^^^^^ > > I seems you prepared memory to be rather persistent! (Just kidding.) > > Sorry, for that non necessary part of code. I, simply used code from a > part of my project where a sqlite file is used and forgot to remove > this part. I was only joking, really. (-: > Thanks for your rapid reaction. Will this patch automatically be part of > the next releases or is it necessary to fill a bug report? Sure, it will be. SQLObject is not such a big project to require Special Bureaucratic Procedures. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Georges S. <geo...@in...> - 2010-10-12 15:18:24
|
On 12/10/2010 15:39, Oleg Broytman wrote: > On Mon, Oct 11, 2010 at 06:17:02PM +0200, Georges Schutz wrote: >> import sqlobject as sobj >> >> class Person(sobj.SQLObject): >> name = sobj.StringCol(default=None) >> >> conn = sobj.connectionForURI('sqlite:/:memory:') >> >> Person.createTable(ifNotExists=True, connection=conn) >> Person(name="P. Dummy", connection=conn) >> >> p = Person.selectBy(name = "P. Dummy", connection=conn) > ... >> File >> "C:\Python26\lib\site-packages\sqlobject-0.14.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 > > Congratulations, you managed to find quite a subtle problem! Sometimes > validators need additional information from connection - most often > validators need encoding (charset) to convert between str and unicode. In > your example there is no per-class connection, and validators don't get a > connection at all. In many cases it could be fixed - the attached patch is > for testing and discussing. > The problem is rather old but it manifested itself now because in > version 0.13 I refactored validators' code. > I applied the attached patch to my 0.14 version which worked with some shift operations. I suppose you did your patch on the head of the trunk. After patching I tested it on the small example code (OK) and on the larger project (at leased on parts of it) and every thing worked as usual, no error any more. --> So for me the patch is OK. >> conn = sobj.connectionForURI('sqlite:/:memory:') >> ^^^^^^^^ >> Person.createTable(ifNotExists=True, connection=conn) > ^^^^^^^^^^^^^^^^ > I seems you prepared memory to be rather persistent! (Just kidding.) Sorry, for that non necessary part of code. I, simply used code from a part of my project where a sqlite file is used and forgot to remove this part. > > Oleg. > > Thanks for your rapid reaction. Will this patch automatically be part of the next releases or is it necessary to fill a bug report? Georges Schutz > > ------------------------------------------------------------------------------ > 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-12 13:39:45
|
On Mon, Oct 11, 2010 at 06:17:02PM +0200, Georges Schutz wrote: > import sqlobject as sobj > > class Person(sobj.SQLObject): > name = sobj.StringCol(default=None) > > conn = sobj.connectionForURI('sqlite:/:memory:') > > Person.createTable(ifNotExists=True, connection=conn) > Person(name="P. Dummy", connection=conn) > > p = Person.selectBy(name = "P. Dummy", connection=conn) ... > File > "C:\Python26\lib\site-packages\sqlobject-0.14.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 Congratulations, you managed to find quite a subtle problem! Sometimes validators need additional information from connection - most often validators need encoding (charset) to convert between str and unicode. In your example there is no per-class connection, and validators don't get a connection at all. In many cases it could be fixed - the attached patch is for testing and discussing. The problem is rather old but it manifested itself now because in version 0.13 I refactored validators' code. > conn = sobj.connectionForURI('sqlite:/:memory:') > ^^^^^^^^ > Person.createTable(ifNotExists=True, connection=conn) ^^^^^^^^^^^^^^^^ I seems you prepared memory to be rather persistent! (Just kidding.) Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-10-12 07:42:12
|
Hello! On Mon, Oct 11, 2010 at 06:17:02PM +0200, Georges Schutz wrote: > AttributeError: No connection has been defined for this thread or process Thank you for the report! I will look at it. > Until at leased version 0.12 this code worked with no problem. I have > not tested the 0.13 version so I don't know if this behaver was yet in > the 0.13 version. > This may be a new Features. Seems to be rather a new bug. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Georges S. <geo...@in...> - 2010-10-12 06:30:18
|
First thank you for all your work. I tested the new version with my projects using SQLObject and encountered the following problem (is the smallest code that reproduces the problem). AttributeError: No connection has been defined for this thread or process Until at leased version 0.12 this code worked with no problem. I have not tested the 0.13 version so I don't know if this behaver was yet in the 0.13 version. This may be a new Features. If so what do I have to do to get the old behaviour back where the connection is passed as parameter. I need this as I access multiple databases for witch the connection is passed to the corresponding class initialisation or even later during runtime of the application. Here the code and the error traceback #--- Code Begin --- import sqlobject as sobj class Person(sobj.SQLObject): name = sobj.StringCol(default=None) conn = sobj.connectionForURI('sqlite:/:memory:') Person.createTable(ifNotExists=True, connection=conn) Person(name="P. Dummy", connection=conn) p = Person.selectBy(name = "P. Dummy", connection=conn) #--- Code End --- Traceback (most recent call last): File "D:\eclipse3.6WS\test_python\dbSQLObject_conn_error_small.py", line 11, in <module> p = Person.selectBy(name = "P. Dummy", connection=conn) File "C:\Python26\lib\site-packages\sqlobject-0.14.0-py2.6.egg\sqlobject\main.py", line 1377, in selectBy conn._SO_columnClause(cls, kw), File "C:\Python26\lib\site-packages\sqlobject-0.14.0-py2.6.egg\sqlobject\dbconnection.py", line 585, in _SO_columnClause value = col.from_python(value, sqlbuilder.SQLObjectState(soClass)) File "C:\Python26\lib\site-packages\sqlobject-0.14.0-py2.6.egg\sqlobject\col.py", line 506, in to_python connection = state.soObject._connection File "C:\Python26\lib\site-packages\sqlobject-0.14.0-py2.6.egg\sqlobject\dbconnection.py", line 837, in __get__ return self.getConnection() File "C:\Python26\lib\site-packages\sqlobject-0.14.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 |
From: Oleg B. <ph...@ph...> - 2010-10-10 14:11:46
|
On Sun, Oct 10, 2010 at 04:42:33PM +0400, Oleg Broytman wrote: > > * The lists of columns/indices/joins are now sorted according to the order > > of declaration. > > About joins: joinDefinitions list is sorted but joins list is not - > SQLObject stores indices into the list so the list can be reordered without > major internal change. Sorry - ...cannot be reordered... Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-10-10 12:42:48
|
On Sun, Oct 10, 2010 at 04:17:28PM +0400, Oleg Broytman wrote: > * The lists of columns/indices/joins are now sorted according to the order > of declaration. About joins: joinDefinitions list is sorted but joins list is not - SQLObject stores indices into the list so the list can be reordered without major internal change. > * Major API change: attribute 'dirty' was moved to sqlmeta. SQLObject is undergoing a period of some major API changes. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-10-10 12:17:44
|
Hello! I'm pleased to announce version 0.14.0, the first stable release of branch 0.14 of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://pypi.python.org/pypi/SQLObject/0.14.0 News and changes: http://sqlobject.org/News.html What's New ========== News since 0.13 --------------- Features & Interface ~~~~~~~~~~~~~~~~~~~~ * The lists of columns/indices/joins are now sorted according to the order of declaration. * ``validator2`` was added to all columns; it is inserted at the beginning of the list of validators, i.e. its ``from_python()`` method is called first, ``to_python()`` is called last, after all validators in the list. * SQLiteConnection's parameter ``use_table_info`` became boolean with default value True; this means the default schema parser is now based on ``PRAGMA table_info()``. * Major API change: attribute 'dirty' was moved to sqlmeta. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-10-05 16:15:57
|
Hello! I'm pleased to announce version 0.14.0b1, the first beta of the upcoming release of branch 0.14 of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.14.0b1dev-r4243 News and changes: http://sqlobject.org/News.html What's New ========== News since 0.13 --------------- Features & Interface ~~~~~~~~~~~~~~~~~~~~ * The lists of columns/indices/joins are now sorted according to the order of creation. * ``validator2`` was added to all columns; it is inserted at the beginning of the list of validators, i.e. its ``from_python()`` method is called first, ``to_python()`` is called last, after all validators in the list. * SQLiteConnection's parameter ``use_table_info`` became boolean with default value True; this means the default schema parser is now based on ``PRAGMA table_info()``. * Major API change: attribute 'dirty' was moved to sqlmeta. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Gregor H. <gh...@gr...> - 2010-09-29 17:21:38
|
Am Wed, 29 Sep 2010 21:05:53 +0400 schrieb Oleg Broytman <ph...@ph...>: > On Wed, Sep 29, 2010 at 06:48:28PM +0200, Gregor Horvath wrote: > > http://groups.google.com/group/python-gis-sig/browse_thread/thread/0c4d7863a278f265, > > but did not find the method _SO_get_geom in the source) > > _SO_get_geom will magically appear after you declare a 'geom' > column. The method will return raw data from the column. Ahh. Ok. Thank you, that's a good starting point.... -- Greg |
From: Oleg B. <ph...@ph...> - 2010-09-29 17:06:06
|
On Wed, Sep 29, 2010 at 06:48:28PM +0200, Gregor Horvath wrote: > http://groups.google.com/group/python-gis-sig/browse_thread/thread/0c4d7863a278f265, > but did not find the method _SO_get_geom in the source) _SO_get_geom will magically appear after you declare a 'geom' column. The method will return raw data from the column. > Is there any interest in a patch to so? IWBN to look at. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Gregor H. <gh...@gr...> - 2010-09-29 16:48:44
|
Hello, I need an integration of PostGIS in sqlobject. Before I reinvent the wheel I'd like to ask if there is something I can build upon or use. I did not find anything usesful in the release source or google. (with one exception http://groups.google.com/group/python-gis-sig/browse_thread/thread/0c4d7863a278f265, but did not find the method _SO_get_geom in the source) At first I will need a geometry column and some sqlbuilder expressions (nearby search etc.) Is there any interest in a patch to so? -- Greg |
From: Oleg B. <ph...@ph...> - 2010-09-24 20:25:54
|
On Fri, Sep 24, 2010 at 01:17:33PM -0700, Octav Chipara wrote: > get_attr(p, 'first_name') # will return the first name In Python (not in SQLObject) this is equivalent to p.first_name. You only need to call getattr if the name of the attribute is in a variable: attr_name = 'first_name' print getattr(p, attr_name) And, BTW, in Python the function is named getattr, not get_attr. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-09-24 20:21:51
|
On Fri, Sep 24, 2010 at 01:11:13PM -0700, Octav Chipara wrote: > Thanks Oleg. BTW, is there an easy way to get attributes of an sqlobject by > their name? For example, if I have a person with attributes first_name and > last_name, however do i go around retrieving them. Could I do something like > Person.get_attr('first_name')? What is Person in your question - an SQLObject class (representing an entire SQL table) or an instance of such class (representing one row for the table)? If it's a class - you need to call Person.select() and loop over the result rows. If it's an instance - just get (or set) Person.first_name: print Person.first_name Person.first_name = 'Octav' Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Octav C. <och...@gm...> - 2010-09-24 20:18:00
|
It seems I answered my own questions. You can do this by using get_attr: p = Person(first_name='', last_name='') get_attr(p, 'first_name') # will return the first name Thanks, -- Octav On Fri, Sep 24, 2010 at 1:11 PM, Octav Chipara <och...@gm...> wrote: > Thanks Oleg. BTW, is there an easy way to get attributes of an sqlobject by > their name? For example, if I have a person with attributes first_name and > last_name, however do i go around retrieving them. Could I do something like > Person.get_attr('first_name')? > > Thanks, > --Octav > > > On Fri, Sep 24, 2010 at 3:06 AM, Oleg Broytman <ph...@ph...> wrote: > >> On Thu, Sep 23, 2010 at 06:51:14PM -0700, Octav Chipara wrote: >> > File >> > >> "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/main.py", >> > line 892, in get >> > val = cls(_SO_fetch_no_create=1) >> > TypeError: __init__() got an unexpected keyword argument >> > '_SO_fetch_no_create >> >> It seems cls here is not an SQLObject class because SQLObject.__init__ >> accepts any keywords arguments. You need to investigate what type is cls. >> >> Oleg. >> -- >> Oleg Broytman http://phd.pp.ru/ ph...@ph... >> Programmers don't die, they just GOSUB without RETURN. >> >> >> ------------------------------------------------------------------------------ >> Nokia and AT&T present the 2010 Calling All Innovators-North America >> contest >> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada >> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in >> marketing >> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store >> http://p.sf.net/sfu/nokia-dev2dev >> _______________________________________________ >> sqlobject-discuss mailing list >> sql...@li... >> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss >> > > |
From: Octav C. <och...@gm...> - 2010-09-24 20:11:42
|
Thanks Oleg. BTW, is there an easy way to get attributes of an sqlobject by their name? For example, if I have a person with attributes first_name and last_name, however do i go around retrieving them. Could I do something like Person.get_attr('first_name')? Thanks, --Octav On Fri, Sep 24, 2010 at 3:06 AM, Oleg Broytman <ph...@ph...> wrote: > On Thu, Sep 23, 2010 at 06:51:14PM -0700, Octav Chipara wrote: > > File > > > "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/main.py", > > line 892, in get > > val = cls(_SO_fetch_no_create=1) > > TypeError: __init__() got an unexpected keyword argument > > '_SO_fetch_no_create > > It seems cls here is not an SQLObject class because SQLObject.__init__ > accepts any keywords arguments. You need to investigate what type is cls. > > Oleg. > -- > Oleg Broytman http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------------------------------ > Nokia and AT&T present the 2010 Calling All Innovators-North America > contest > Create new apps & games for the Nokia N8 for consumers in U.S. and Canada > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in > marketing > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store > http://p.sf.net/sfu/nokia-dev2dev > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Oleg B. <ph...@ph...> - 2010-09-24 10:06:54
|
On Thu, Sep 23, 2010 at 06:51:14PM -0700, Octav Chipara wrote: > File > "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/main.py", > line 892, in get > val = cls(_SO_fetch_no_create=1) > TypeError: __init__() got an unexpected keyword argument > '_SO_fetch_no_create It seems cls here is not an SQLObject class because SQLObject.__init__ accepts any keywords arguments. You need to investigate what type is cls. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Octav C. <och...@gm...> - 2010-09-24 01:51:40
|
Hi, I'm getting the following strange exception when using sqlobject. This occurs quite infrequently (after 1-2 mins of operation). Have you guys seen anything similar to this? File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 522, in __bootstrap_inner self.run() ..... for result in results: File "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/sresults.py", line 179, in __iter__ return iter(list(self.lazyIter())) File "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/dbconnection.py", line 665, in next obj = self.select.sourceClass.get(result[0], selectResults=result[1:], connection=self.dbconn) File "/Library/Python/2.6/site-packages/SQLObject-0.13.0-py2.6.egg/sqlobject/main.py", line 892, in get val = cls(_SO_fetch_no_create=1) TypeError: __init__() got an unexpected keyword argument '_SO_fetch_no_create Thanks, -- Octav |
From: Oleg B. <ph...@ph...> - 2010-09-15 12:02:24
|
On Wed, Sep 15, 2010 at 03:49:37PM +0400, Oleg Broytman wrote: > On Wed, Sep 15, 2010 at 07:34:06AM -0400, ed...@la... wrote: > > 1/Query : ALTER TABLE user_phonelists ADD UNIQUE unique (user_id, > > phonelist_id) > > What version of SQLObject and on what backend do you use it? Aha, I see - it's MySQL. Well, the syntax is ALTER TABLE tname ADD UNIQUE [index_name] (index_col_name,...) The problem is the name of the index - 'unique'. Try to rename it: user_phonelist_unique = index.DatabaseIndex(user, phonelist, unique=True) Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-09-15 11:49:47
|
On Wed, Sep 15, 2010 at 07:34:06AM -0400, ed...@la... wrote: > I'm following the example given in the SQLObject FAQ on creating custom > mtm relationships. Creating the unique index for the UserPhonelists table > seems to create an incorrect SQL statement. > > My code: > --- > class User(SQLObject): > name = StringCol(length=255, default="") > [...] > phonelists = > SQLRelatedJoin('Phonelist',intermediateTable='user_phonelists',createRelatedTable=False) > > class Phonelist(SQLObject): > name = StringCol(length=255) > [...] > users = > SQLRelatedJoin('User',intermediateTable='user_phonelists',createRelatedTable=False) > > class UserPhonelists(SQLObject): > class sqlmeta: > table = "user_phonelists" > user = ForeignKey('User', notNull=True, cascade=True) > phonelist = ForeignKey('Phonelist', notNull=True, cascade=True) > [...] > unique = index.DatabaseIndex(user, phonelist, unique=True) > --- > > The queries it generates: > --- > 1/Query : ALTER TABLE user_phonelists ADD CONSTRAINT > user_phonelists_user_id_exists FOREIGN KEY (user_id) REFERENCES user (id) > ON DELETE CASCADE > 1/Query : ALTER TABLE user_phonelists ADD CONSTRAINT > user_phonelists_phonelist_id_exists FOREIGN KEY (phonelist_id) REFERENCES > phonelist (id) ON DELETE CASCADE > 1/Query : ALTER TABLE user_phonelists ADD UNIQUE unique (user_id, > phonelist_id) > --- > > The error the last query triggers: > --- > sqlobject.dberrors.ProgrammingError: You have an error in your SQL syntax; > check the manual that corresponds to your MySQL server version for the > right syntax to use near 'unique (user_id, phonelist_id)' at line 1 > --- You code generates the following statement for me: CREATE UNIQUE INDEX user_phonelists_unique ON user_phonelists (user_id, phonelist_id) SQLObject 0.13.0, SQLite. And the code u = User(name='1') pl = Phonelist(name='1') pl.addUser(u) pl.addUser(u) correctly produces the error: sqlobject.dberrors.DuplicateEntryError: columns user_id, phonelist_id are not unique What version of SQLObject and on what backend do you use it? Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: <ed...@la...> - 2010-09-15 11:34:15
|
I'm following the example given in the SQLObject FAQ on creating custom mtm relationships. Creating the unique index for the UserPhonelists table seems to create an incorrect SQL statement. My code: --- class User(SQLObject): name = StringCol(length=255, default="") [...] phonelists = SQLRelatedJoin('Phonelist',intermediateTable='user_phonelists',createRelatedTable=False) class Phonelist(SQLObject): name = StringCol(length=255) [...] users = SQLRelatedJoin('User',intermediateTable='user_phonelists',createRelatedTable=False) class UserPhonelists(SQLObject): class sqlmeta: table = "user_phonelists" user = ForeignKey('User', notNull=True, cascade=True) phonelist = ForeignKey('Phonelist', notNull=True, cascade=True) [...] unique = index.DatabaseIndex(user, phonelist, unique=True) --- The queries it generates: --- 1/Query : ALTER TABLE user_phonelists ADD CONSTRAINT user_phonelists_user_id_exists FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE 1/Query : ALTER TABLE user_phonelists ADD CONSTRAINT user_phonelists_phonelist_id_exists FOREIGN KEY (phonelist_id) REFERENCES phonelist (id) ON DELETE CASCADE 1/Query : ALTER TABLE user_phonelists ADD UNIQUE unique (user_id, phonelist_id) --- The error the last query triggers: --- sqlobject.dberrors.ProgrammingError: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'unique (user_id, phonelist_id)' at line 1 --- Shouldn't the generated statement be: --- ALTER TABLE user_phonelists ADD UNIQUE (user_id, phonelist_id); --- Regards, Ed |
From: Oleg B. <ph...@ph...> - 2010-08-20 17:54:44
|
On Fri, Aug 20, 2010 at 01:43:32PM -0400, luis cota wrote: > I have a pre-defined table in a SQL Server database that contains 4 columns > + the primary key (integer). My class in Python is defined as: > > class HistoricalMatrix(SQLObject): > class sqlmeta: > fromDatabase = True > table="HistoricalMatrix" > ccy = StringCol(length = 4) > dataDate = DateCol() > handle = StringCol(length = 128) > coeff = StringCol() > > the columns in the database are: > id > ccy > data_date > handle > coeff > > The data_date column is specified as "data_date" in the database - is there > a way I can specify this in the class definition? I came about using the > mixed-case setup after some errors declaring the field as data_date in my > Python class. dataDate = DateCol(dbName='date_date') Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |