sqlobject-discuss Mailing List for SQLObject (Page 54)
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-05-15 17:43:48
|
On Fri, May 15, 2009 at 10:09:01AM -0700, Daniel Fetchinson wrote: > Actually, I think TimedeltaCol could be implemented for sqlite as > well. Although it doesn't have an INTERVAL data type it could use a > plain TEXT instead and python would do the conversion. As far as I > know sqlite only knows TEXT anyway so IntCol, StringCol, etc, all > these things are implemented as TEXT and the data conversion is done > by python. The TimedeltaCol could be similar. Well, not exactly - SQLite understands and produces some data types - pysqlite passes them unmodified AFAIU. But anyway I did a similar trick with DecimalStringCol - it stores decimals as strings to work around SQLite's "type affinity" feature. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Daniel F. <fet...@go...> - 2009-05-15 17:09:07
|
>> Here's another test, added to the bottom of test_converters.py: > > Thanks! > >> By the way, how do I write a converter that converts a python object one >> way for one database (sqlite) and another way for another database >> (postgres)? Are there any examples of this already? > > Yes, see StringLikeConverter. Actually, I think TimedeltaCol could be implemented for sqlite as well. Although it doesn't have an INTERVAL data type it could use a plain TEXT instead and python would do the conversion. As far as I know sqlite only knows TEXT anyway so IntCol, StringCol, etc, all these things are implemented as TEXT and the data conversion is done by python. The TimedeltaCol could be similar. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Oleg B. <ph...@ph...> - 2009-05-14 15:03:54
|
On Thu, May 14, 2009 at 02:53:57PM +0000, Matthew Wilson wrote: > The test_dynamicJoin method in sqlobject/tests/test_auto.py causes a segfault for me: > > $ py.test --verbose test_auto.py > python: platform linux2 -- Python 2.5.2 -- /home/matt/virtualenvs/scratch/bin/python > using py lib: /home/matt/virtualenvs/scratch/lib/python2.5/site-packages/py-1.0.0b1-py2.5.egg/py <rev unknown> > test object 1: /home/matt/checkouts/SQLObject/sqlobject/tests/test_auto.py > > /home/matt/svn-checkouts/SQLObject/sqlobject/tests/test_auto.py:36: TestPeople.test_defaultOrder PASS > /home/matt/svn-checkouts/SQLObject/sqlobject/tests/test_auto.py:40: TestPeople.test_dynamicColumn PASS > /home/matt/svn-checkouts/SQLObject/sqlobject/tests/test_auto.py:48: TestPeople.test_dynamicJoin Segmentation fault > > Anyone else seeing this problem? Works for me: ============================= test session starts ============================== python: platform linux2 -- Python 2.5.2 -- /usr/bin/python using py lib: /usr/local/src/Python/py-dist/py <rev 65166> test object 1: /home/phd/work/SQLObject/SQLObject-trunk/sqlobject/tests/test_auto.py test_auto.py:36: TestPeople.test_defaultOrder PASS test_auto.py:40: TestPeople.test_dynamicColumn PASS test_auto.py:48: TestPeople.test_dynamicJoin PASS test_auto.py:68: TestPeople.test_collidingName PASS test_auto.py:170: TestAuto.test_classCreate PASS =========================== 5 passed in 0.67 seconds =========================== Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Matthew W. <ma...@tp...> - 2009-05-14 14:54:29
|
The test_dynamicJoin method in sqlobject/tests/test_auto.py causes a segfault for me: $ py.test --verbose test_auto.py python: platform linux2 -- Python 2.5.2 -- /home/matt/virtualenvs/scratch/bin/python using py lib: /home/matt/virtualenvs/scratch/lib/python2.5/site-packages/py-1.0.0b1-py2.5.egg/py <rev unknown> test object 1: /home/matt/checkouts/SQLObject/sqlobject/tests/test_auto.py /home/matt/svn-checkouts/SQLObject/sqlobject/tests/test_auto.py:36: TestPeople.test_defaultOrder PASS /home/matt/svn-checkouts/SQLObject/sqlobject/tests/test_auto.py:40: TestPeople.test_dynamicColumn PASS /home/matt/svn-checkouts/SQLObject/sqlobject/tests/test_auto.py:48: TestPeople.test_dynamicJoin Segmentation fault Anyone else seeing this problem? |
From: Oleg B. <ph...@ph...> - 2009-05-14 14:37:26
|
On Thu, May 14, 2009 at 02:32:31PM +0000, Matthew Wilson wrote: > Here's another test, added to the bottom of test_converters.py: Thanks! > By the way, how do I write a converter that converts a python object one > way for one database (sqlite) and another way for another database > (postgres)? Are there any examples of this already? Yes, see StringLikeConverter. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Matthew W. <ma...@tp...> - 2009-05-14 14:32:52
|
On Thu 14 May 2009 10:18:47 AM EDT, Matthew Wilson wrote: > On Wed 13 May 2009 04:35:59 PM EDT, Oleg Broytmann wrote: >> On Wed, May 13, 2009 at 08:05:26PM +0000, Matthew Wilson wrote: >>> > IWBN to have a test also. >>> >>> I completely agree; can you point me to where in the code I should write >>> the test? Also, are there any tests I can use as a guide? >> >> Any test script would be ok - I'll convert it to the test suit myself. >> But of course a test in SQLObject style would be even better. >> SQLObject uses py.test as its testing environment. You can find a lot of >> tests in sqlobject/tests/ directory. Here's another test, added to the bottom of test_converters.py: $ svn diff test_converters.py Index: test_converters.py =================================================================== --- test_converters.py (revision 3881) +++ test_converters.py (working copy) @@ -1,4 +1,5 @@ import sys +from datetime import timedelta from sqlobject.sqlbuilder import sqlrepr from sqlobject.sqlbuilder import SQLExpression, SQLObjectField, \ Select, Insert, Update, Delete, Replace, \ @@ -195,3 +196,8 @@ pass else: assert sqlrepr(Set([1])) == "(1)" + +def test_timedeltas(): + + assert sqlrepr(timedelta(seconds=30*60)) == \ + "INTERVAL '0 days 1800 seconds'" By the way, how do I write a converter that converts a python object one way for one database (sqlite) and another way for another database (postgres)? Are there any examples of this already? |
From: Oleg B. <ph...@ph...> - 2009-05-14 14:29:55
|
On Thu, May 14, 2009 at 02:18:47PM +0000, Matthew Wilson wrote: > I'm trying to write a test, but it seems like all the tests use a sqlite > database, and sqlite doesn't support an interval datatype. > > Not sure what to do at this point. Here's the test (absolutely > nothing fancy here): > > $ cat test_interval.py > # vim: set expandtab ts=4 sw=4 filetype=python: > > from datetime import timedelta > > from sqlobject import * > from sqlobject.tests.dbtest import * > > class Student(SQLObject): > break_time = TimedeltaCol() > > def test_timedeltaCol(): > setupClass(Student) > td = timedelta(seconds=60*60) > student = Student(break_time=td) > assert student.break_time == td > > When I run py.test test_interval.py, I get an operational error that > comes from sqlite rejecting the interval syntax. > > Ideas? Should I create a postgresql database in my setup method and > then connect to that for my test? It should be something like $ createdb test $ py.test test_interval.py -D postgres:/test $ dropdb test Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Matthew W. <ma...@tp...> - 2009-05-14 14:19:09
|
On Wed 13 May 2009 04:35:59 PM EDT, Oleg Broytmann wrote: > On Wed, May 13, 2009 at 08:05:26PM +0000, Matthew Wilson wrote: >> > IWBN to have a test also. >> >> I completely agree; can you point me to where in the code I should write >> the test? Also, are there any tests I can use as a guide? > > Any test script would be ok - I'll convert it to the test suit myself. > But of course a test in SQLObject style would be even better. > SQLObject uses py.test as its testing environment. You can find a lot of > tests in sqlobject/tests/ directory. I'm trying to write a test, but it seems like all the tests use a sqlite database, and sqlite doesn't support an interval datatype. Not sure what to do at this point. Here's the test (absolutely nothing fancy here): $ cat test_interval.py # vim: set expandtab ts=4 sw=4 filetype=python: from datetime import timedelta from sqlobject import * from sqlobject.tests.dbtest import * class Student(SQLObject): break_time = TimedeltaCol() def test_timedeltaCol(): setupClass(Student) td = timedelta(seconds=60*60) student = Student(break_time=td) assert student.break_time == td When I run py.test test_interval.py, I get an operational error that comes from sqlite rejecting the interval syntax. Ideas? Should I create a postgresql database in my setup method and then connect to that for my test? |
From: Oleg B. <ph...@ph...> - 2009-05-13 20:36:03
|
On Wed, May 13, 2009 at 08:05:26PM +0000, Matthew Wilson wrote: > > IWBN to have a test also. > > I completely agree; can you point me to where in the code I should write > the test? Also, are there any tests I can use as a guide? Any test script would be ok - I'll convert it to the test suit myself. But of course a test in SQLObject style would be even better. SQLObject uses py.test as its testing environment. You can find a lot of tests in sqlobject/tests/ directory. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Matthew W. <ma...@tp...> - 2009-05-13 20:05:50
|
On Wed 13 May 2009 03:39:01 PM EDT, Oleg Broytmann wrote: > On Wed, May 13, 2009 at 07:11:22PM +0000, Matthew Wilson wrote: >> Hi -- I wrote some code to add a TimedeltaCol type. I only tested it in >> postgresql. > > Thank you! > >> +def TimedeltaConverter(value, db): >> + >> + return """INTERVAL '%d days %d seconds'""" % \ >> + (value.days, value.seconds) >> + >> +registerConverter(datetime.timedelta, TimedeltaConverter) > > The syntax is only valid in Postgres, so it has to be protected: > > def TimedeltaConverter(value, db): > if db == 'postgres': > return """INTERVAL '%d days %d seconds'""" % \ > (value.days, value.seconds) > else: > raise ValueError('TimedeltaCol is only implemented for Postgres') > >> +class TimedeltaValidator(validators.Validator): >> + def to_python(self, value, state): >> + return value >> + >> + def from_python(self, value, state): >> + return value > > Why empty validator? > > IWBN to have a test also. I completely agree; can you point me to where in the code I should write the test? Also, are there any tests I can use as a guide? Later this week, I'll try to send in an updated patch with the code you added and a test. Matt |
From: Oleg B. <ph...@ph...> - 2009-05-13 19:39:06
|
On Wed, May 13, 2009 at 07:11:22PM +0000, Matthew Wilson wrote: > Hi -- I wrote some code to add a TimedeltaCol type. I only tested it in > postgresql. Thank you! > +def TimedeltaConverter(value, db): > + > + return """INTERVAL '%d days %d seconds'""" % \ > + (value.days, value.seconds) > + > +registerConverter(datetime.timedelta, TimedeltaConverter) The syntax is only valid in Postgres, so it has to be protected: def TimedeltaConverter(value, db): if db == 'postgres': return """INTERVAL '%d days %d seconds'""" % \ (value.days, value.seconds) else: raise ValueError('TimedeltaCol is only implemented for Postgres') > +class TimedeltaValidator(validators.Validator): > + def to_python(self, value, state): > + return value > + > + def from_python(self, value, state): > + return value Why empty validator? IWBN to have a test also. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Matthew W. <ma...@tp...> - 2009-05-13 19:11:44
|
Hi -- I wrote some code to add a TimedeltaCol type. I only tested it in postgresql. I'll improve this code if you tell me what I should do. I find the SQLOjbect internals confusing. Matt Index: converters.py =================================================================== --- converters.py (revision 3881) +++ converters.py (working copy) @@ -187,6 +187,14 @@ registerConverter(Decimal, DecimalConverter) +def TimedeltaConverter(value, db): + + return """INTERVAL '%d days %d seconds'""" % \ + (value.days, value.seconds) + +registerConverter(datetime.timedelta, TimedeltaConverter) + + def sqlrepr(obj, db=None): try: reprFunc = obj.__sqlrepr__ Index: col.py =================================================================== --- col.py (revision 3881) +++ col.py (working copy) @@ -1517,6 +1517,32 @@ baseClass = SOPickleCol +class TimedeltaValidator(validators.Validator): + + def to_python(self, value, state): + return value + + def from_python(self, value, state): + return value + + +class SOTimedeltaCol(SOCol): + + def _postgresType(self): + return 'INTERVAL' + + def createValidators(self): + return [TimedeltaValidator(name=self.name)] + \ + super(SOTimedeltaCol, self).createValidators() + + + +class TimedeltaCol(Col): + baseClass = SOTimedeltaCol + + + + def pushKey(kw, name, value): if not kw.has_key(name): kw[name] = value |
From: Oleg B. <ph...@ph...> - 2009-05-13 07:01:31
|
On Tue, May 12, 2009 at 07:47:10PM -0400, Andrew Peace wrote: > class Item(SQLObject): > """An item definition (e.g. 'The Life of Brian DVD')""" > name = StringCol(length=15, alternateID=True) > attributes = MultipleJoin('ItemAttribute') > > class Attribute(SQLObject): > """An attribute definition (e.g. ISBN is a String)""" > #columns > name = StringCol(length=10, alternateID=True) > title = StringCol(length=20) > dataType = IntCol(length=1) > > class ItemAttribute(SQLObject): > """An attribute instantiation (e.g. ISBN='abcd1234')""" > item = ForeignKey('Item', cascade=True) > attribute = ForeignKey('Attribute') > value = StringCol(length=50) > > SELECT item.* > FROM item > LEFT JOIN item_attribute as item_attribute0 ON item.id = item_attribute0.item_id > LEFT JOIN attribute as attribute0 on attribute0.id = > item_attribute0.attribute_id > LEFT JOIN item_attribute as item_attribute1 ON item_attribute0.item_id > = item_attribute1.item_id > LEFT JOIN attribute as attribute1 on attribute1.id = > item_attribute1.attribute_id > WHERE 1 > AND attribute0.name = 'price' > AND item_attribute0.value = '19.99' > AND attribute1.name = 'isbn' > AND item_attribute1.value = 'life123'; from sqlobject.sqlbuilder import Alias, LEFTJOINOn attribute0 = Alias(Attribute, 'attribute0') item_attribute0 = Alias(ItemAttribute, 'item_attribute0') item_attribute1 = Alias(ItemAttribute, 'item_attribute1') and then something like this: Item.select( join=[ LEFTJOINOn(None, item_attribute0, Item.q.id == item_attribute0.q.itemID), LEFTJOINOn(None, attribute0, attribute0.q.id == item_attribute0.q.attributeID), ... other left joins ... ], clause = ( (attribute0.q.name == 'price') && (item_attribute0.q.value == 19.99) && ... other where clauses ... ) ) Or, if you prefer this form clause = AND( (attribute0.q.name == 'price'), (item_attribute0.q.value == 19.99), ... other where clauses ... ) Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Andrew P. <ap...@gm...> - 2009-05-12 23:47:16
|
I have quite a complex query, and I am trying to select from the database with SQLObject instead of using the query directly. Here is the table structure: class Item(SQLObject): """An item definition (e.g. 'The Life of Brian DVD')""" name = StringCol(length=15, alternateID=True) attributes = MultipleJoin('ItemAttribute') class Attribute(SQLObject): """An attribute definition (e.g. ISBN is a String)""" #columns name = StringCol(length=10, alternateID=True) title = StringCol(length=20) dataType = IntCol(length=1) class ItemAttribute(SQLObject): """An attribute instantiation (e.g. ISBN='abcd1234')""" item = ForeignKey('Item', cascade=True) attribute = ForeignKey('Attribute') value = StringCol(length=50) As you can see, each item may have zero or more item_attributes. Each item_attribute relates to exactly one attribute, which gives it an attribute name. Here is my query: SELECT item.* FROM item LEFT JOIN item_attribute as item_attribute0 ON item.id = item_attribute0.item_id LEFT JOIN attribute as attribute0 on attribute0.id = item_attribute0.attribute_id LEFT JOIN item_attribute as item_attribute1 ON item_attribute0.item_id = item_attribute1.item_id LEFT JOIN attribute as attribute1 on attribute1.id = item_attribute1.attribute_id WHERE 1 AND attribute0.name = 'price' AND item_attribute0.value = '19.99' AND attribute1.name = 'isbn' AND item_attribute1.value = 'life123'; In this specific example, the query (in MySQL) selects all items that have a price of 19.99 and ISBN of 'life123'. More generally, I use queries like this to select items that have certain attributes. Each attribute I am searching for creates two left joins, one for the item_attribute itself and one for the attribute's name. Not sure how to make such a selection through the SQLObject ORM. Any help is greatly appreciated! -Andrew Peace |
From: Oleg B. <ph...@ph...> - 2009-05-12 19:03:44
|
On Tue, May 12, 2009 at 02:57:38PM -0400, inhahe wrote: > On Tue, May 12, 2009 at 4:00 AM, Oleg Broytmann <ph...@ph...> wrote: > > On Tue, May 12, 2009 at 03:08:16AM -0400, inhahe wrote: > > > try: > > > Pics.createTable() > > > print "Created table Pics" > > > except dberrors.OperationalError: pass > > > > Why do you need these try/except? > > i want it to create each table but only if the table doesn't already exist Pics.createTable(ifNotExists=True) Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: inhahe <in...@gm...> - 2009-05-12 18:57:57
|
On Tue, May 12, 2009 at 4:00 AM, Oleg Broytmann <ph...@ph...> wrote: > On Tue, May 12, 2009 at 03:08:16AM -0400, inhahe wrote: > > class Pics(SQLObject): > > itemid = IntCol() > > picdata = BLOBCol() > > thumbnail = ForeignKey("Thumbs", cascade='null') > > try: > > Pics.createTable() > > print "Created table Pics" > > except dberrors.OperationalError: pass > > Why do you need these try/except? i want it to create each table but only if the table doesn't already exist if it already exists it gives me an operationalerror. i had tried looking for a better way but couldn't find one! > > http://sqlobject.org/FAQ.html#mutually-referencing-tables > > ah, thanks |
From: Oleg B. <ph...@ph...> - 2009-05-12 08:00:27
|
On Tue, May 12, 2009 at 03:08:16AM -0400, inhahe wrote: > class Pics(SQLObject): > itemid = IntCol() > picdata = BLOBCol() > thumbnail = ForeignKey("Thumbs", cascade='null') > try: > Pics.createTable() > print "Created table Pics" > except dberrors.OperationalError: pass Why do you need these try/except? > class Thumbs(SQLObject): > itemid = IntCol() > pic = ForeignKey("Pics", cascade=True) > picdata = BLOBCol() > try: > Pics.createTable() > print "Created table Pics" > except dberrors.OperationalError: pass > > KeyError: 'No class Thumbs found in the registry http://sqlobject.org/FAQ.html#mutually-referencing-tables Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: inhahe <in...@gm...> - 2009-05-12 07:08:28
|
sorry if there was something in the documentation i should have understood, but i'm having this problem the code: class Pics(SQLObject): itemid = IntCol() picdata = BLOBCol() thumbnail = ForeignKey("Thumbs", cascade='null') try: Pics.createTable() print "Created table Pics" except dberrors.OperationalError: pass class Thumbs(SQLObject): itemid = IntCol() pic = ForeignKey("Pics", cascade=True) picdata = BLOBCol() try: Pics.createTable() print "Created table Pics" except dberrors.OperationalError: pass the error: KeyError: 'No class Thumbs found in the registry [default] (these classes exist: Log, Pics, RegisterSessions, SQLObject, Sessions, Users)' that list is a list of all the tables created before i got to that point, so i assume the error is that Thumbs must be registered before I can make a foreign key to it, but then if I put Thumbs before Pics, Pics wouldn't be registered yet when I try to make a foreign key to that. how do i solve this? sorry if the answer is supposed to be obvious =p |
From: Daniel F. <fet...@go...> - 2009-05-12 01:25:07
|
>> > Hello! I am going to do the next round of minor releases. Does anybody >> > need >> > a beta period? >> >> Oooops, I missed this announcement. In general I don't need a beta >> period at all, since if the new versions are not okay, I can simply >> switch back to the older version. > > I usually don't make betas for minor releases but this time there were > many changes (albeit minor ones) in a long period without release. Makes perfect sense. In any case it's good to see that sqlobject is alive! Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Oleg B. <ph...@ph...> - 2009-05-11 17:35:53
|
On Mon, May 11, 2009 at 10:30:56AM -0700, Daniel Fetchinson wrote: > > Hello! I am going to do the next round of minor releases. Does anybody need > > a beta period? > > Oooops, I missed this announcement. In general I don't need a beta > period at all, since if the new versions are not okay, I can simply > switch back to the older version. I usually don't make betas for minor releases but this time there were many changes (albeit minor ones) in a long period without release. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Daniel F. <fet...@go...> - 2009-05-11 17:31:02
|
> Hello! I am going to do the next round of minor releases. Does anybody need > a beta period? Oooops, I missed this announcement. In general I don't need a beta period at all, since if the new versions are not okay, I can simply switch back to the older version. The new 0.10.5 version works perfectly with my app, thanks for the hard work! Cheers, Danil -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Daniel F. <fet...@go...> - 2009-05-11 17:28:25
|
> Since revision 3880 SQLObject works with Python 2.6; actually, it worked > just fine even before but it raised a DeprecationWarning on import sets; > now it doesn't and is fully tested with SQLite and Postgres. On the next > releases (0.10.6 and 0.11) there will be python eggs for 2.6. This is great, thanks a lot, Oleg! Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Oleg B. <ph...@ph...> - 2009-05-11 06:57:58
|
Since revision 3880 SQLObject works with Python 2.6; actually, it worked just fine even before but it raised a DeprecationWarning on import sets; now it doesn't and is fully tested with SQLite and Postgres. On the next releases (0.10.6 and 0.11) there will be python eggs for 2.6. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2009-05-06 12:21:44
|
Hello! I'm pleased to announce version 0.10.5, a minor bugfix release of 0.10 branch 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.10.5 News and changes: http://sqlobject.org/News.html What's New ========== News since 0.10.4 ----------------- * Another unicode-related patch for MySQL; required because different versions of MySQLdb require different handling:: - MySQLdb < 1.2.1: only ascii - MySQLdb = 1.2.1: only unicode - MySQLdb > 1.2.1: both ascii and unicode * Setup requires FormEncode version 1.1.1+. * Fixed a minor bug - pass name to DecimalValidator. * Fixed a bug in InheritableIteration - pass connection to child klass.select(). * sqlmeta.getColumns() becomes classmethod. * A bug was fixed in PostgresConnection.columnsFromSchema() - foreign keys are now recognized and created as proper ForeignKey with correct column name and table name. * Bugs in PostgresConnection and MSSQLConnection related to properties was fixed. A note for developers: from now on properties in DBConnection classes are forbidden as they don't work with Transaction - Transaction.__getattr__() cannot properly wrap 'self' so a property is called with wrong 'self'. * Transaction instances now explicitly raises TypeError on close() - without this calling Transaction.close() calls connection.close() which is wrong. * A bug in SQLiteConnection.columnsFromSchema() that led to an infinite loop was fixed. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2009-05-06 12:08:35
|
Hello! I'm pleased to announce version 0.9.10, a minor bugfix release of 0.9 branch 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.9.10 News and changes: http://sqlobject.org/News.html What's New ========== News since 0.9.9 ---------------- * Another unicode-related patch for MySQL; required because different versions of MySQLdb require different handling:: - MySQLdb < 1.2.1: only ascii - MySQLdb = 1.2.1: only unicode - MySQLdb > 1.2.1: both ascii and unicode * Setup requires FormEncode version 1.1.1+. * Fixed a minor bug - pass name to DecimalValidator. * Fixed a bug in InheritableIteration - pass connection to child klass.select(). * A bug was fixed in PostgresConnection.columnsFromSchema() - foreign keys are now recognized and created as proper ForeignKey with correct column name and table name. * Bugs in PostgresConnection and MSSQLConnection related to properties was fixed. A note for developers: from now on properties in DBConnection classes are forbidden as they don't work with Transaction - Transaction.__getattr__() cannot properly wrap 'self' so a property is called with wrong 'self'. * Transaction instances now explicitly raises TypeError on close() - without this calling Transaction.close() calls connection.close() which is wrong. * A bug in SQLiteConnection.columnsFromSchema() that led to an infinite loop was fixed. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |