sqlobject-discuss Mailing List for SQLObject (Page 56)
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...> - 2009-03-27 16:31:59
|
On Fri, Mar 27, 2009 at 07:17:03PM +0300, Oleg Broytmann wrote: > On Fri, Mar 27, 2009 at 10:58:37AM -0500, Kevin Rice wrote: > > I have a patch for a bug I found in the DecimalValidator class in col.py. I > > am getting messages saying no attribute 'name' of DecimalValidator. This is > > is traceable to col.py, about line 1300: > > Thank you for spotting this. I'll fix it but in a different manner - by > passing correct name to the DecimalValidator. Fixed in the revisions 3636-3638 - branches 0.9, 0.10 and the trunk. Will be in the next round of releases. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2009-03-27 16:17:15
|
On Fri, Mar 27, 2009 at 10:58:37AM -0500, Kevin Rice wrote: > I have a patch for a bug I found in the DecimalValidator class in col.py. I > am getting messages saying no attribute 'name' of DecimalValidator. This is > is traceable to col.py, about line 1300: Thank you for spotting this. I'll fix it but in a different manner - by passing correct name to the DecimalValidator. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Kevin R. <jus...@gm...> - 2009-03-27 15:58:43
|
I have a patch for a bug I found in the DecimalValidator class in col.py. I am getting messages saying no attribute 'name' of DecimalValidator. This is is traceable to col.py, about line 1300: def from_python(self, value, state): if value is None: return None if isinstance(value, float): value = str(value) if isinstance(value, (str, unicode)): connection = state.soObject._connection if hasattr(connection, "decimalSeparator"): value = value.replace(connection.decimalSeparator, ".") try: return Decimal(value) except: raise validators.Invalid("can not parse Decimal value '%s' in the DecimalCol from '%s'" % (value, getattr(state, 'soObject', '(unknown)')), value, state) if not isinstance(value, (int, long, Decimal, sqlbuilder.SQLExpression)): raise validators.Invalid("expected a decimal in the DecimalCol '%s', got %s %r instead" % \ (getattr(self, 'name', '(unknown name)'), type(value), value), value, state) return value The change is in the next-to-last line (the raise() call). The problem, as I mentioned, is DecimalValidator having no attribute 'name' (a reference to self.name). Changing self.name to getattr(self, 'name', '(unknown name)')eliminates this problem and preserves a nice error message showing you what the problem is. Likewise, there’s a line above this in the to_python() method that could/should be changed similarly. Sorry, I don’t know how to create a test for this, my code is rather complex. -- Kevin |
From: Daniel F. <fet...@go...> - 2009-03-13 23:12:07
|
> Hi Daniel > Hi Oleg, > > I don´t know how to realize this with union but i think this should do it > > > # plain sql would be sth like this (untested) > select * from comment > where (object='zoo' and object_id=?) > or (object='cage' and object_id in (select id from cage where zoo=?)) > or (object='animal' and object_id in (select id from animal where cage > in (select id from cage where zoo=?))) > > > > > # could be translated to python with sqlbuilder to sth like this (untested) > > from sqlobject.sqlbuilder import * > aZoo = zoo.get(?) > someAnimals = [animal.id for animal in aCage.animals for aCage in > aZoo.cages] > > sql = SELECT(OR( > AND(comment.q.object == 'zoo', comment.q.object_id == ? ), > AND(comment.q.object == 'cage', IN(comment.q.object_id, aZoo.cages) ), > AND(comment.q.object == 'animal', IN(comment.q.object_id, someAnimals)) > )) > > result = comment._connection.queryAll(sql) > > didn´t test it but i think this should work? > maybe the subselect for animals can be included into a single select > select statement in sqlbuilder as well...? > > HTH, > Frank > > > On Thu, Mar 12, 2009 at 10:16, Oleg Broytmann <ph...@ph...> wrote: >> On Wed, Mar 11, 2009 at 06:52:17PM -0700, Daniel Fetchinson wrote: >>> Unfortunately I haven't found >>> working examples of SQLBuilder + UNION constructions so far, if I >>> don't manage to get it right I'll probably come back :) >> >> If you manage to get it right please come back anyway and show us an >> example! :) Hi Frank, thanks a lot for this example! I'll test this and let you guys know if it worked for me or not. Since I couldn't get this working with a single query I simply did multiple different queries and combined the results in python. But if your solution works that would be even better. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Frank W. <fra...@no...> - 2009-03-12 14:16:13
|
Hi Daniel Hi Oleg, I don´t know how to realize this with union but i think this should do it # plain sql would be sth like this (untested) select * from comment where (object='zoo' and object_id=?) or (object='cage' and object_id in (select id from cage where zoo=?)) or (object='animal' and object_id in (select id from animal where cage in (select id from cage where zoo=?))) # could be translated to python with sqlbuilder to sth like this (untested) from sqlobject.sqlbuilder import * aZoo = zoo.get(?) someAnimals = [animal.id for animal in aCage.animals for aCage in aZoo.cages] sql = SELECT(OR( AND(comment.q.object == 'zoo', comment.q.object_id == ? ), AND(comment.q.object == 'cage', IN(comment.q.object_id, aZoo.cages) ), AND(comment.q.object == 'animal', IN(comment.q.object_id, someAnimals)) )) result = comment._connection.queryAll(sql) didn´t test it but i think this should work? maybe the subselect for animals can be included into a single select select statement in sqlbuilder as well...? HTH, Frank On Thu, Mar 12, 2009 at 10:16, Oleg Broytmann <ph...@ph...> wrote: > On Wed, Mar 11, 2009 at 06:52:17PM -0700, Daniel Fetchinson wrote: >> Unfortunately I haven't found >> working examples of SQLBuilder + UNION constructions so far, if I >> don't manage to get it right I'll probably come back :) > > If you manage to get it right please come back anyway and show us an > example! :) > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Oleg B. <ph...@ph...> - 2009-03-12 09:16:42
|
On Wed, Mar 11, 2009 at 06:52:17PM -0700, Daniel Fetchinson wrote: > Unfortunately I haven't found > working examples of SQLBuilder + UNION constructions so far, if I > don't manage to get it right I'll probably come back :) If you manage to get it right please come back anyway and show us an example! :) Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Daniel F. <fet...@go...> - 2009-03-12 01:52:31
|
>> class comment( SQLObject ): >> object_id = Int( ) # this is the 'id' of the object this comment >> is associated to >> object_ = StringCol( validator=OneOf( [ 'animal', 'cage', 'zoo' ] >> ) ) # type of object >> content = UnicodeCol( ) # the actual comment >> >> select all comments that belong either to this zoo instance or to >> any cage in this zoo or any animal that is in a cage in the zoo? > > With such a setup the only way I can see is to issue a complex UNION > query that unions 3 different queries - SELECT comments for zoo, cages and > animals. > UNION queries are, of course, impossible with SQLObject tables but > possible with SQLBuilder. Thanks Oleg, I'll look at SQLBuilder. Unfortunately I haven't found working examples of SQLBuilder + UNION constructions so far, if I don't manage to get it right I'll probably come back :) Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Oleg B. <ph...@ph...> - 2009-03-11 09:36:24
|
On Tue, Mar 10, 2009 at 11:59:33PM -0700, Daniel Fetchinson wrote: > class comment( SQLObject ): > object_id = Int( ) # this is the 'id' of the object this comment > is associated to > object_ = StringCol( validator=OneOf( [ 'animal', 'cage', 'zoo' ] > ) ) # type of object > content = UnicodeCol( ) # the actual comment > > select all comments that belong either to this zoo instance or to > any cage in this zoo or any animal that is in a cage in the zoo? With such a setup the only way I can see is to issue a complex UNION query that unions 3 different queries - SELECT comments for zoo, cages and animals. UNION queries are, of course, impossible with SQLObject tables but possible with SQLBuilder. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Daniel F. <fet...@go...> - 2009-03-11 06:59:41
|
I'm sorry to come up again with a complex query question but I simply couldn't find a simple solution for this. My schema is the following: there are zoos, zoos have cages, cages have animals. And to any of these objects comments can be associated. For a given zoo I need to select all comments that are either: comments on the zoo OR comments on a cage belonging to this zoo OR comments on an animal belonging to a cage belonging to this zoo. The schema is this: class zoo( SQLObject ): cages = MultipleJoin( 'cage' ) class cage( SQLObject ): animals = MultipleJoin( 'animal' ) zoo = ForeignKey( 'zoo' ) class animal( SQLObject ): cage = ForeignKey( 'cage' ) class comment( SQLObject ): object_id = Int( ) # this is the 'id' of the object this comment is associated to object_ = StringCol( validator=OneOf( [ 'animal', 'cage', 'zoo' ] ) ) # type of object content = UnicodeCol( ) # the actual comment It might very well be the case that this setup is not optimal but unfortunately I can't change it. So given a zoo instance with comments on zoos, cages and animals, does anyone know an elegant query that will select all comments that belong either to this zoo instance or to any cage in this zoo or any animal that is in a cage in the zoo? Thanks very much for any help, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Oleg B. <ph...@ph...> - 2009-03-04 16:56:49
|
On Wed, Mar 04, 2009 at 04:51:17PM +0000, wzi...@co... wrote: > (Though I'll try not to bother you for a few days!) Actually, you can't. (-: Tomorrow I am leaving the town (even the country) for a short vacation. Will be back March 9, late at night. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: <wzi...@co...> - 2009-03-04 16:51:23
|
No need to apologize; your help has been invaluable. It's working well now, so it's on to joins and other challenges! (Though I'll try not to bother you for a few days!) Thanks again, ....WZ ----- Original Message ----- From: "Oleg Broytmann" <ph...@ph...> To: sql...@li... Sent: Wednesday, March 4, 2009 4:22:59 PM GMT +00:00 Monrovia Subject: Re: [SQLObject] cannot insert with Sybase On Wed, Mar 04, 2009 at 04:13:54PM +0000, wzi...@co... wrote: > Hello Oleg and others, > > But if I use 'id' instead of 'title_id' I get: > > File "/diska/data/workspace/PyXtern/Bibliothek/eggs/SQLObject-0.10.4-py2.5.egg/sqlobject/main.py", line 1203, in __init__ > File "/diska/data/workspace/PyXtern/Bibliothek/eggs/SQLObject-0.10.4-py2.5.egg/sqlobject/main.py", line 1237, in _create > TypeError: titles() did not get expected keyword argument 'title_id' Oops, my fault, sorry. You must not declare the 'id' column. > I hope it helps if I use dots to preserve the indentation: > ======================================= > from.sqlobject.import.* > > class.titles(.SQLObject.): > > ....title_id = IntCol() > ....title = StringCol() > > ....class.sqlmeta: > ........print.'class.sqlmeta' > ........idName = 'title_id' > ........lazyUpdate = False Remove 'title_id = IntCol()' from the class declaration. idName is the only way to name the column, and 'id' is the only way to refer to the column. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H _______________________________________________ sqlobject-discuss mailing list sql...@li... https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss |
From: Oleg B. <ph...@ph...> - 2009-03-04 16:23:09
|
On Wed, Mar 04, 2009 at 04:13:54PM +0000, wzi...@co... wrote: > Hello Oleg and others, > > But if I use 'id' instead of 'title_id' I get: > > File "/diska/data/workspace/PyXtern/Bibliothek/eggs/SQLObject-0.10.4-py2.5.egg/sqlobject/main.py", line 1203, in __init__ > File "/diska/data/workspace/PyXtern/Bibliothek/eggs/SQLObject-0.10.4-py2.5.egg/sqlobject/main.py", line 1237, in _create > TypeError: titles() did not get expected keyword argument 'title_id' Oops, my fault, sorry. You must not declare the 'id' column. > I hope it helps if I use dots to preserve the indentation: > ======================================= > from.sqlobject.import.* > > class.titles(.SQLObject.): > > ....title_id = IntCol() > ....title = StringCol() > > ....class.sqlmeta: > ........print.'class.sqlmeta' > ........idName = 'title_id' > ........lazyUpdate = False Remove 'title_id = IntCol()' from the class declaration. idName is the only way to name the column, and 'id' is the only way to refer to the column. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: <wzi...@co...> - 2009-03-04 16:14:04
|
Hello Oleg and others, But if I use 'id' instead of 'title_id' I get: File "/diska/data/workspace/PyXtern/Bibliothek/eggs/SQLObject-0.10.4-py2.5.egg/sqlobject/main.py", line 1203, in __init__ File "/diska/data/workspace/PyXtern/Bibliothek/eggs/SQLObject-0.10.4-py2.5.egg/sqlobject/main.py", line 1237, in _create TypeError: titles() did not get expected keyword argument 'title_id' I hope it helps if I use dots to preserve the indentation: ======================================= from.sqlobject.import.* class.titles(.SQLObject.): ....title_id = IntCol() ....title = StringCol() ....class.sqlmeta: ........print.'class.sqlmeta' ........idName = 'title_id' ........lazyUpdate = False ======================================= second class to insert a row: ======================================= from sqlobject import * import titles class InsertNewTitle: ....def makeNewBook( self ): ........sybURI = "sybase://my_user_id:my_password@DBSERVER//library_info" ........konnection = connectionForURI(sybURI) ........konnection.debug = True ........konnection.autoCommit = True ........sqlhub.processConnection = konnection ........newKey = 1237 ........newTitle = "Mystery Book" ........book_b = titles.titles(id=newKey, title=newTitle) ........print 'for ID %d the title is %s' % (book_b.id, book_b.title) ........return None if __name__ == "__main__": ....instantiatedObject = InsertNewTitle() ....instantiatedObject.makeNewBook() ========================================= I also tried mixing various combinations of 'id' and 'title_id' in the two locations but an error always results, with no indication what it really wants. Thanks very much, ....WZ |
From: Oleg B. <ph...@ph...> - 2009-03-04 10:56:01
|
On Wed, Mar 04, 2009 at 10:31:31AM +0000, wzi...@co... wrote: > from sqlobject import * > > class titles( SQLObject ): > > title_id = IntCol() > title = StringCol() > > class sqlmeta: > print 'class sqlmeta' > idName = 'title_id' [skip] > newKey = 1234 > newTitle = "Mystery Book" > book_b = titles.titles(title_id=newKey, title=newTitle) Throughout entire SQLObject the 'id' column is called 'id'. After you named your column 'title_id' in sqlmeta you have to use 'id' name for the column: book_b = titles.titles(id=newKey, title=newTitle) Without that SQLObject thinks id is None and creates a new id by asking the backend - see sqlobject/sybase/sybaseconnection.py, methods _queryInsertId() and insert_id(). insert_id() creates a new id (0) and then SQLObject tries to SELECT the row back by that id. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: <wzi...@co...> - 2009-03-04 10:31:34
|
Hello Oleg and others, Thanks sincerely for the help; I'm much further along because now rows are inserted successfully. However, I still get an odd error message referring to key 0 when I do a simple print to show the values in the object. BTW, I will do my best to preserve indenting but my web-based email service is determined to ruin the code. better class 1: =========================================================== from sqlobject import * class titles( SQLObject ): title_id = IntCol() title = StringCol() class sqlmeta: print 'class sqlmeta' idName = 'title_id' lazyUpdate = False =========================================================== better class 2: =========================================================== from sqlobject import * import titles class InsertNewTitle: def makeNewBook( self ): sybURI = "sybase://my_user_id:my_password@DBSERVER//library_info" konnection = connectionForURI( sybURI ) konnection.debug = True konnection.autoCommit = True sqlhub.processConnection = konnection newKey = 1234 newTitle = "Mystery Book" book_b = titles.titles(title_id=newKey, title=newTitle) # works! # book_b.id = newKey # book_b.set(title_id=newKey, title = newTitle) # book_b.syncUpdate() # book_b = titles.get(newKey) print 'for ID %d the title is %s' % ( book_b.title_id, book_b.title ) # fails return None if __name__ == "__main__": instantiatedObject = InsertNewTitle() instantiatedObject.makeNewBook() =========================================================== and the error and the messages I cannot prevent are: =========================================================== class sqlmeta QueryIns: INSERT INTO titles (title_id, title) VALUES (1234, 'Mystery Book') 1/QueryOne: SELECT title_id, title FROM titles WHERE ((titles.title_id) = (0)) 1/QueryR : SELECT title_id, title FROM titles WHERE ((titles.title_id) = (0)) Traceback (most recent call last): File "/diska/data/workspace/PyXtern/src/tmpTry/InsertNewTitle.py", line 30, in <module> instantiatedObject.makeNewBook() File "/diska/data/workspace/PyXtern/src/tmpTry/InsertNewTitle.py", line 18, in makeNewBook book_b = titles.titles(title_id=newKey, title=newTitle) File "/diska/data/workspace/PyXtern/Bibliothek/eggs/SQLObject-0.10.4-py2.5.egg/sqlobject/main.py", line 1203, in __init__ File "/diska/data/workspace/PyXtern/Bibliothek/eggs/SQLObject-0.10.4-py2.5.egg/sqlobject/main.py", line 1251, in _create File "/diska/data/workspace/PyXtern/Bibliothek/eggs/SQLObject-0.10.4-py2.5.egg/sqlobject/main.py", line 1278, in _SO_finishCreate File "/diska/data/workspace/PyXtern/Bibliothek/eggs/SQLObject-0.10.4-py2.5.egg/sqlobject/main.py", line 931, in _init sqlobject.main.SQLObjectNotFound: The object titles by the ID 0 does not exist =========================================================== Note the commented code showing ways I have tried to persuade the object to think about my new key, but clearly it remains focused on key 0 which does not exist in the database, so the commented lines did not help. What might be the appropriate remedy for this error? Again thank you for the timely help, .....WZ |
From: Oleg B. <ph...@ph...> - 2009-03-03 18:18:24
|
On Tue, Mar 03, 2009 at 05:55:43PM +0000, wzi...@co... wrote: > class sqlmeta: > print 'class sqlmeta' > idName = 'title_id' > lazyUpdate = False > autoCommit = True sqlmeta doesn't have 'autoCommit' attribute. (It'd also be helpful to send python code properly formatted.) > book_a._connection.debug = True > book_a._connection.autoCommit = True It is too late to set this after creating a row. The settings should be set on the 'konnection' before inserting. > This code actually appears to work with no errors, but I can run it > many times with no duplicate rows because nothing gets inserted into > the database. No commit has been done. > I tried wrapping it all in a transaction and doing a > commit, but that didn't help. It'd be interesting to see the code. > It's not a permission problem Certainly not - with a permission problem you'd get an exception. > Note I instantiate two books. I don't want to, but I'm forced to > because if I try to give it a non-zero first key I get the error: > "sqlobject.main.SQLObjectNotFound: The object titles by the ID 0 > does not exist" ....even though I'm providing a non-zero key! Please show the debugging output and the entire traceback. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: <wzi...@co...> - 2009-03-03 17:55:44
|
Hello, ... has anyone gotten SQLObject to work with Sybase? I can query the database but I can't insert. Any advice would be appreciated. The table already exists and is extremely simple, with just two columns, a key and a text string. Here's the class for the table: ========================================== from sqlobject import * class titles( SQLObject ): title_id = IntCol() title = StringCol() class sqlmeta: print 'class sqlmeta' idName = 'title_id' lazyUpdate = False autoCommit = True ========================================== And here's a separate class where I attempt to insert: ========================================== from sqlobject import * import titles class InsertNewTitle: def __init__( self, newKey, newTitle ): sybURI = "sybase://my_user_id:my_password@DBSERVER//library_info" konnection = connectionForURI( sybURI ) sqlhub.processConnection = konnection book_a = titles.titles(title_id=0, title='zero') book_a._connection.debug = True book_a._connection.autoCommit = True book_b = titles.titles(title_id=newKey, title=newTitle) book_b._connection.debug = True book_b._connection.autoCommit = True book_b.id = newKey book_b.set(title_id=newKey, title = newTitle) book_b.syncUpdate() print 'for ID %d the title is %s' % ( book_b.title_id, book_b.title ) return None if __name__ == "__main__": instantiatedObject = InsertNewTitle(506,"Spy Story") ========================================== This code actually appears to work with no errors, but I can run it many times with no duplicate rows because nothing gets inserted into the database. I tried wrapping it all in a transaction and doing a commit, but that didn't help. It's not a permission problem because I've used the same ID and password in an SQL tool and I can insert. Note I instantiate two books. I don't want to, but I'm forced to because if I try to give it a non-zero first key I get the error: "sqlobject.main.SQLObjectNotFound: The object titles by the ID 0 does not exist" ....even though I'm providing a non-zero key! So I have 2 questions, if anyone would be kind enough to help: why does it complain about 0 not existing when I create only one book using a non-zero key (but doesn't complain as long as I use the 2 book work-around shown) and why does nothing get written to the database, even when I put in a commit? Thanks in advance for any help. .....WZ |
From: Gabriel <ga...@op...> - 2009-02-21 23:16:26
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Oleg Broytmann escribió: > I added a call to send RowUpdatedSignal after .set(); also added > post-functions for both signals. I didn't use your tests - instead I copied > and modified test_row_update and test_row_destroy in tests/test_events.py. > Everything is now in the trunk, commit 3792. Will be in 0.11 when it > will be released. > > Oleg. Good to know :) Thanks. - -- Kind regards. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEAREIAAYFAkmgix0ACgkQNHr4BkRe3pKiIACdHQF5t9OEfnRDSg6DQH+Awrgp hwMAnROBS3bxPPMRqBh9eFW39xHLhT8O =hHmF -----END PGP SIGNATURE----- |
From: Oleg B. <ph...@ph...> - 2009-02-21 18:44:37
|
On Fri, Feb 20, 2009 at 11:28:50AM -0200, Gabriel wrote: > Attached patch with new events RowDestroyedSignal and RowUpdatedSignal. I added a call to send RowUpdatedSignal after .set(); also added post-functions for both signals. I didn't use your tests - instead I copied and modified test_row_update and test_row_destroy in tests/test_events.py. Everything is now in the trunk, commit 3792. Will be in 0.11 when it will be released. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2009-02-20 13:33:23
|
On Fri, Feb 20, 2009 at 11:28:50AM -0200, Gabriel wrote: > Attached patch with new events RowDestroyedSignal and RowUpdatedSignal. Thank you! I will look at it... I hope, tomorrow... Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Gabriel <ga...@op...> - 2009-02-20 13:28:54
|
On Thu, Feb 19, 2009 at 4:24 PM, Oleg Broytmann <ph...@ph...> wrote: > On Thu, Feb 19, 2009 at 04:04:16PM -0200, Gabriel wrote: >> just a question, are you planning to add events RowDestroyedSignal and >> RowUpdatedSignal, in other words events that are invoked after and not >> before like de actual ones. >> Just the same as RowCreatedSignal and RowCreateSignal > > I don't, but you are welcome to provide a patch and a test. > > Oleg. Attached patch with new events RowDestroyedSignal and RowUpdatedSignal. gmail doesn't allow me to send the test in a file, so I'm pasting it here, sorry. -- Kind Regards #---- TEST FOR EVENTS ---- from sqlobject import * from sqlobject.events import listen, RowDestroySignal, RowCreatedSignal, RowDestroyedSignal, RowUpdateSignal, RowUpdatedSignal database = 'sqlite:/temp/test.db' conn = connectionForURI(database + "?debug=1") sqlhub.processConnection = conn class A(SQLObject): class sqlmeta: lazyUpdate = True name = StringCol() def rowCreated(arg, post): print "CREATED" print list(A.select()) def rowDelete(inst, post): print "BEFORE DELETE" print list(A.select()) def rowDeleted(inst): print "DELETED" print list(A.select()) def rowUpdate(inst, args): print "UPDATE" print list(A.select()) def rowUpdated(inst): print "UPDATED" print list(A.select()) listen(rowCreated, A, RowCreatedSignal) listen(rowDelete, A, RowDestroySignal) listen(rowDeleted, A, RowDestroyedSignal) listen(rowUpdate, A, RowUpdateSignal) listen(rowUpdated, A, RowUpdatedSignal) A.createTable() print "INSERTING DATA" a = A(name="Pepe") a = A.get(1) a.name = "Pepe2" a.syncUpdate() a.destroySelf() |
From: Oleg B. <ph...@ph...> - 2009-02-19 18:25:06
|
On Thu, Feb 19, 2009 at 04:04:16PM -0200, Gabriel wrote: > just a question, are you planning to add events RowDestroyedSignal and > RowUpdatedSignal, in other words events that are invoked after and not > before like de actual ones. > Just the same as RowCreatedSignal and RowCreateSignal I don't, but you are welcome to provide a patch and a test. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Gabriel <ga...@op...> - 2009-02-19 18:04:20
|
Hi all, just a question, are you planning to add events RowDestroyedSignal and RowUpdatedSignal, in other words events that are invoked after and not before like de actual ones. Just the same as RowCreatedSignal and RowCreateSignal -- Kind Regards |
From: Oleg B. <ph...@ph...> - 2009-02-19 13:48:26
|
On Thu, Feb 19, 2009 at 02:22:18PM +0100, Christian Widmer wrote: > It would be nice, however to > have something like ClassName.upgrade() similar to ClassName.create(), > that takes into account differences and performs the appropriate ALTER > operation. Most certainly, it would be nice. Wanna work on the feature? Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Christian W. <cw...@tu...> - 2009-02-19 13:22:31
|
Oleg Broytmann wrote: > On Thu, Feb 19, 2009 at 12:25:43PM +0100, Christian Widmer wrote: > >> "sqlobject-admin upgrade -h" says: >> This command runs scripts (that you write by hand) to upgrade a database.... >> >> Does this mean, that I end up having to manually update the table >> definition AND the class definition each time? >> > > Well, in any case you have to manually update table definitions. But you > can use a different approach - SQLObject can draw table definitions from > the DB iteslf; of course in this case you have to manually alter tables. > > >> Is there no way to create >> a "diff" between the class defined in python and the current database >> scheme automatically? >> > > I think "sqlobject-admin status" and "sqlobject-admin record" may help. > Thanks for your quick reply, Oleg. I looked at sqlobject-admin status and record, and in deed "status" recognizes that the python class definition and the table are out-of-sync. It would be nice, however to have something like ClassName.upgrade() similar to ClassName.create(), that takes into account differences and performs the appropriate ALTER operation. cheers, Chris |