sqlobject-discuss Mailing List for SQLObject (Page 57)
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-02-19 13:11:40
|
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. 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 11:25:50
|
Hi all, in the past I've worked on some projects using ruby-on-rails. I found the "migrations" framework very useful, that allows to semi-automatically keep track of an evolving database scheme. In particular, I am facing the following problem. I have a class definition, which also defines my database scheme. By now I have already generated a number of datasets which populate latter database. The problem now is that I need additional fields in my database. I see two obvious solutions to this: 1) drop and recreate database with new scheme 2) manually alter my tables according to my class definitions 1) is not an option, and I would like to avoid going with 2) every time I need to add a column. As mentioned before, ruby-on-rails provides some tools to update a database scheme semi-automatically, once the corresponding class definition has been changed. A google search pointed me to a tool called sqlobject-admin, which seems to be able to do something similar. However, from the documentation (http://www.sqlobject.org/sqlobject-admin.html), it was not obvious to me how to achieve this. "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? Is there no way to create a "diff" between the class defined in python and the current database scheme automatically? Help would be appreciated, Chris |
From: Oleg B. <ph...@ph...> - 2009-02-09 18:08:51
|
On Mon, Feb 09, 2009 at 01:03:53PM -0500, Stef Telford wrote: > Oleg Broytmann wrote: > > Oh, BTW, do you use transactions? And call transaction.commit()? > > > I don't see why/how wrapping everything in a transaction would > change things.. but then.. that's jst me :) Transaction object in SQLObject closes the connection on commit. To prevent it to do so call transaction.commit(close=False) But you don't use transactions, so I am out of ideas. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Stef T. <st...@um...> - 2009-02-09 18:04:03
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Oleg Broytmann wrote: > Oh, BTW, do you use transactions? And call transaction.commit()? > > Oleg. Hello again Oleg, Nope, well, I mean I -plan- to, but currently, the connection is being made at the start of the page and then I go through get'ting and init'ing objects. There isn't even any saving done, this is purely rendering content stage. Also, if I print out the memory location, it's always the same throughout the entire page rendering (eg; 8f000c). I don't see why/how wrapping everything in a transaction would change things.. but then.. that's jst me :) Regards Stef -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJkHAFANG7uQ+9D9URAp9RAJ4qckdiDz4qYzYcPgxvS38AkNGPLQCfW9B2 kS+qqCMw5evqf+rDGUdvGhM= =9x/A -----END PGP SIGNATURE----- |
From: Oleg B. <ph...@ph...> - 2009-02-09 17:57:33
|
Oh, BTW, do you use transactions? And call transaction.commit()? 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-09 17:50:38
|
On Mon, Feb 09, 2009 at 12:35:47PM -0500, Stef Telford wrote: > slaveConnection._pool = None It must be exactly opposite: slaveConnection._pool = [] Well, an empty list is the default value, so by default SQLObject should not disconnect but use a low-level connection from the pool. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Stef T. <st...@um...> - 2009-02-09 17:35:49
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Oleg Broytmann wrote: > On Sun, Feb 08, 2009 at 06:16:01PM -0500, Stef Telford wrote: >> seeing about 190 connects/disconnects on the postgreSQL side. >> Now, since a connection is costly (believe me, it is ;), how can >> I get these down to (in theory) 1. I know that may seem >> unrealistic, but still, there shouldn't be 190 >> connects/disconnects. >> >> This -is- a single threaded environment, I do print out during >> the select in main.py and the connection -is- the same (same >> memory ref), I don't use selectBy either. >> >> I am kind of scratching my head here. Could it be that the joins >> in the class don't honor the classes connection? > > Whatever joins use - they use SQLObject's DBConnection objects that > are high-level wrapper around Python DB API connections. Every > DBConnection instance maintains a pool of opened DB API connections > and opens a new DB API connection only if the pool is empty (the > first query or all DB API connections are busy in other threads). > Hence there shouldn't be connects/disconnects, especially in a > single-threaded program. The only way to make implicit > connects/disconnects is to disable connection pooling. You haven't > done that, have you? connection._pool is not None? > > Oleg. Hello again Oleg, Actually, I -have- done this.. both with and without it seems to make no difference, I still get a tonne of connections :(. I have tried doing; > slaveConnection = getConnectionURI() slaveConnection._pool = None I have also tried specifically changing dbconnection.py self._pool = [] to self._pool = None .. no joy there either :( If I am doing something wrong, feel free to smack me upside the head and tell me ;) I am inheriting inside myclass from SQLObject, I am passing in the single connection via the overloaded get, _init and select/selectBy (not that I use selectBy but.. yes) Regards Stef -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJkGltANG7uQ+9D9URAvFwAKCEHbonXnqgNSqCKrFW0RaUtFKHqACff+sZ b3Ud/xwYc86imYtDRNXwWFE= =Cagq -----END PGP SIGNATURE----- |
From: Oleg B. <ph...@ph...> - 2009-02-09 14:44:14
|
On Sun, Feb 08, 2009 at 06:16:01PM -0500, Stef Telford wrote: > seeing about 190 connects/disconnects on the postgreSQL side. Now, > since a connection is costly (believe me, it is ;), how can I get > these down to (in theory) 1. I know that may seem unrealistic, but > still, there shouldn't be 190 connects/disconnects. > > This -is- a single threaded environment, I do print out during the > select in main.py and the connection -is- the same (same memory ref), > I don't use selectBy either. > > I am kind of scratching my head here. Could it be that the joins > in the class don't honor the classes connection? Whatever joins use - they use SQLObject's DBConnection objects that are high-level wrapper around Python DB API connections. Every DBConnection instance maintains a pool of opened DB API connections and opens a new DB API connection only if the pool is empty (the first query or all DB API connections are busy in other threads). Hence there shouldn't be connects/disconnects, especially in a single-threaded program. The only way to make implicit connects/disconnects is to disable connection pooling. You haven't done that, have you? connection._pool is not None? Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Stef T. <st...@um...> - 2009-02-08 23:16:05
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hey Oleg, Everyone, So, I have currently subclassed SQLObject to MySQLObject, as I am trying to basically do one connection to a slave, another to a master. Hopefully, that makes sense so far. In my class I have subclassed get and select to use an existing connection. Eg; > @classmethod > def select(self, clause=None, **kwargs): > ''' All selects should go through the slave connection ''' > global slaveConnection > if slaveConnection: > kwargs['connection']=slaveConnection > return super(CompassObject, self).select(clause, **kwargs) and the same for 'get' as well.. the curious thing is, I am still seeing about 190 connects/disconnects on the postgreSQL side. Now, since a connection is costly (believe me, it is ;), how can I get these down to (in theory) 1. I know that may seem unrealistic, but still, there shouldn't be 190 connects/disconnects. This -is- a single threaded environment, I do print out during the select in main.py and the connection -is- the same (same memory ref), I don't use selectBy either. I am kind of scratching my head here. Could it be that the joins in the class don't honor the classes connection ? (would be kind of strange and not at all what I would expect.. nor do I see that the code is creating a new connection). Any thoughts/ideas gratefully welcomed ;) Regards Stef -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJj2exANG7uQ+9D9URApPRAKCFyMWs7eM4DDB1wYSQsGcRbbvoZgCdEPOQ Ru1Xc6xHVkceP0Hd21eLIMM= =WPA5 -----END PGP SIGNATURE----- |
From: Dan P. <da...@ag...> - 2009-02-04 22:21:39
|
On Tuesday 03 February 2009, Oleg Broytmann wrote: > On Tue, Feb 03, 2009 at 02:37:16PM -0500, Stef Telford wrote: > > Oleg Broytmann wrote: > > > Because SQLObject needs to generate unique alias names and a global > > > counter is the simplest way to do it. Think about joining a table > > > with itself - you need two different names for the table. > > > > Sorry, perhaps I am being stupid here (always a possability) but, how > > many self joins are we expecting in a query ? I mean to say, isn't > > saying 'selfName = self.__class__.__name__ + "_%d" % int(random())' > > good enough ? > > Are you sure calling random() and int() is really so much faster > than lock/increase counter/unlock? > Are you sure you are optimizing a real stumbling block? I do not think that the issue is one of speed, but one of correctness. Locks plus an incrementing counter is safe and correct. Random numbers are not. While they may work most of the time, they may also fail under given circumstances which is unacceptable. -- Dan |
From: Oleg B. <ph...@ph...> - 2009-02-03 20:45:43
|
On Tue, Feb 03, 2009 at 02:37:16PM -0500, Stef Telford wrote: > Oleg Broytmann wrote: > > Because SQLObject needs to generate unique alias names and a global > > counter is the simplest way to do it. Think about joining a table > > with itself - you need two different names for the table. > > Sorry, perhaps I am being stupid here (always a possability) but, how > many self joins are we expecting in a query ? I mean to say, isn't > saying 'selfName = self.__class__.__name__ + "_%d" % int(random())' > good enough ? Are you sure calling random() and int() is really so much faster than lock/increase counter/unlock? Are you sure you are optimizing a real stumbling block? > it seems crazy to call _setattr_ if the row has been grabbed from the > cache (as any call to setattr would/should invalidate the object in > the cache and force a reload from the database). What __setattr__ do you mean? SQLObject doesn't have __setattr__, so it doesn't invalidate object, and certainly doesn't reload it from DB. > Think of 'completeName' .. which is simply self.firstName + " " + > self.lastName. I can think of a 'good reason' to only call -that- > after the initial object has been created (I know that this should be > a model function which jst returns the firstName + " " + lastName but, > go with me here, I am trying to keep my example simple). > > If there is a 'newRowInDB' flag, then I can say something like; > > def _init(self, id, connection=None, selectResults=None): ''' > > Overload this method if you need to do anything special ''' > > SQLObject._init(self, id, connection, selectResults) if > > self.newRowInDB: self.completeName = self.firstName + " " + > > self.lastName memcache.put("%s_%s" % (self.__class__.__name__, > > self.id)) ._SO_finishCreate() and ._init() are only called on create (INSERT) and not called when the object is fetched from the cache so you don't need a flag here - just set self.completeName in your overridden _init(). Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Stef T. <st...@um...> - 2009-02-03 19:45:01
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Oleg Broytmann wrote: > On Mon, Feb 02, 2009 at 09:39:06PM -0500, Stef Telford wrote: >> Oleg Broytmann wrote: >>> On Mon, Feb 02, 2009 at 03:07:49PM -0500, Stef Telford wrote: >>>> alias's will stay 'fixed' at webserver/framework launch .. no >>>> ? >>> Alias counter is increased on every instantiation of Alias(). >> Stupid question here .. but .. why ? (sorry, I know that this >> could be a large answer but..) > > Because SQLObject needs to generate unique alias names and a global > counter is the simplest way to do it. Think about joining a table > with itself - you need two different names for the table. > Thanks for your time once again Oleg. but. Sorry, perhaps I am being stupid here (always a possability) but, how many self joins are we expecting in a query ? I mean to say, isn't saying 'selfName = self.__class__.__name__ + "_%d" % int(random())' good enough ? I don't know about how mySQL planner would deal with a self join on a self join .. but I can guess (eg; NOT well) so .. surely we only need to worry about -1- self join per table in any query ? and since queries are always 'stand alone' we don't have to worry about leakage to other areas/queries, why not merely chose a random number and append ? Sorry, I guess I am not grasping the fine details here.. my apologies :) >> Also, whilst I am here, a couple more stupid questions, is there >> any flag in the SQLObject which tells me if the object was >> 'created' from the database or instantiated from the >> database/cache ? I ask only because it would be -awfully- handy >> to have .. I did look at _creating but, that's not the right item >> (obviously) > > There is no and I really fail to see a difference. Why do you want > to distinguish them? > Really ? Well, in my application, there is a lot of 'house keeping' that needs to be done after a new row is created in the database, and it seems crazy to call _setattr_ if the row has been grabbed from the cache (as any call to setattr would/should invalidate the object in the cache and force a reload from the database). Think of 'completeName' .. which is simply self.firstName + " " + self.lastName. I can think of a 'good reason' to only call -that- after the initial object has been created (I know that this should be a model function which jst returns the firstName + " " + lastName but, go with me here, I am trying to keep my example simple). If there is a 'newRowInDB' flag, then I can say something like; > def _init(self, id, connection=None, selectResults=None): ''' > Overload this method if you need to do anything special ''' > SQLObject._init(self, id, connection, selectResults) if > self.newRowInDB: self.completeName = self.firstName + " " + > self.lastName memcache.put("%s_%s" % (self.__class__.__name__, > self.id)) If we -dont- have that newRowInDB flag, then any cache hit will call the _setattr_ on completeName, which will thus (potentially) invalidate the object in the cache and cause another get for SQLObject .. which will cause _setattr_ to be called... round and round we go. I think even having a flag set on self somewhere inside the _SO_finishCreate would do the trick, but, I am assuming that this is the only place that creates new objects in the db. >> Lastly (I promise) I am thinking of over-riding the >> _SO_finishCreate in the SQLObject subclass so that all database >> inserts go to the master rather than any slave. I would also have >> to override _SO_setValue and set (of course) .. any other methods >> in SQLObject that would have to be subclassed ? > > No, these seem to be enough. > Danke. Regards Stef > Oleg. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD4DBQFJiJzsANG7uQ+9D9URAtgcAJjHdYSZ4UV4fHp9UwBFqQ4A8JJ1AJ9yKfAN gT7kfXEpCT/vivcHB6u+9A== =zN9m -----END PGP SIGNATURE----- |
From: Stef M. <ste...@gm...> - 2009-02-03 19:17:23
|
Oleg Broytmann wrote: > On Tue, Feb 03, 2009 at 06:14:24PM +0100, Stef Mientki wrote: > >>> Well, we use sqlite:///path/to/data.base syntax with ':' replaced by >>> '|': sqlite:///C|program/data.db. This is how we do it: >>> >> This is absolutely weird >> > > Not at all. This is how web-browsers used to support file://-URLs on > w32. > That must be a long time ago, for decades I use "file:///D:/...." > >> There seems to have been more problems with table names and columns names, >> but the above states clear that underscores are allowed. >> The error complains about invalid column names, >> so apparently it has read the table information, >> and the table names are so simple 'Field1', 'Field2' , etc >> >> Or I'm doing something completely wrong, >> or I do things different from other users ( e.g. starting with already >> existing database), >> or no-one has really tested SQLObject with sqlite3. >> Any other possibilities ? ;-) >> > > Or trying to use SQLObject with a database that SQLObject fails to > handle. SQLObject has some requirements, most notable - there have to be > a primary key in the table, of type INT or CHAR, with the name 'id'; if > it's not named 'id' you have to provide an explicit name: > > class MyTable(SQLObject): > class sqlmeta: > idName = 'my_id' > > That explains. thanks Oleg, cheers, Stef |
From: Oleg B. <ph...@ph...> - 2009-02-03 17:51:37
|
On Tue, Feb 03, 2009 at 06:14:24PM +0100, Stef Mientki wrote: > > Well, we use sqlite:///path/to/data.base syntax with ':' replaced by > > '|': sqlite:///C|program/data.db. This is how we do it: > > This is absolutely weird Not at all. This is how web-browsers used to support file://-URLs on w32. > There seems to have been more problems with table names and columns names, > but the above states clear that underscores are allowed. > The error complains about invalid column names, > so apparently it has read the table information, > and the table names are so simple 'Field1', 'Field2' , etc > > Or I'm doing something completely wrong, > or I do things different from other users ( e.g. starting with already > existing database), > or no-one has really tested SQLObject with sqlite3. > Any other possibilities ? ;-) Or trying to use SQLObject with a database that SQLObject fails to handle. SQLObject has some requirements, most notable - there have to be a primary key in the table, of type INT or CHAR, with the name 'id'; if it's not named 'id' you have to provide an explicit name: class MyTable(SQLObject): class sqlmeta: idName = 'my_id' Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Stef M. <ste...@gm...> - 2009-02-03 17:14:28
|
On Tue, Feb 3, 2009 at 12:04 AM, Oleg Broytmann <ph...@ph...> wrote: > On Mon, Feb 02, 2009 at 10:46:42PM +0100, Stef Mientki wrote: > > now I think there's a slash too much :-( > > Now I wonder, is SQLObject suited for MS-Windows ? > > My company sells commercial programs for w32; some of these programs use > SQLObject pretty heavily. On the server side we use SQLite for small > clients > and PostgreSQL for bigger ones. > Well, we use sqlite:///path/to/data.base syntax with ':' replaced by > '|': sqlite:///C|program/data.db. This is how we do it: > > cwd = os.getcwd() > cwd_uri = cwd.replace(os.sep, '/') > if os.name == 'nt': > cwd_uri = '/' + cwd_uri.replace(':', '|') This is absolutely weird, I've never seen this in my whole live ! Must be a Linux trick ;-) > > > > ValueError: The table test__create2 ws not found in the database. Load > > failed > > > > Now it's creating an extra underscore ??? > > No idea. I am sure it is not an SQLObject's error. As I've nowhere typed 2 underscores in my 5 lines of code, and I only use SQLObject, despite I don't have any understanding of SQLObject, I definitely say it's a SQLObject bug !! If on the error line, I explictly fill in the correct tablename (with just 1 underscore), the program runs a bit further, and now stops here: # This isn't strictly true, since we *could* use backquotes or # " or something (database-specific) around column names, but # why would anyone *want* to use a name like that? # @@: I suppose we could actually add backquotes to the # dbName if we needed to... if not forceDBName: assert sqlbuilder.sqlIdentifier(name), 'Name must be SQL-safe (letters, numbers, underscores): %s (or use forceDBName=True)' \ % repr(name) assert name != 'id', 'The column name "id" is reserved for SQLObject use (and is implicitly created).' assert name, "You must provide a name for all columns" There seems to have been more problems with table names and columns names, but the above states clear that underscores are allowed. The error complains about invalid column names, so apparently it has read the table information, and the table names are so simple 'Field1', 'Field2' , etc Or I'm doing something completely wrong, or I do things different from other users ( e.g. starting with already existing database), or no-one has really tested SQLObject with sqlite3. Any other possibilities ? ;-) thanks, Stef Mientki > > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------------------------------ > Create and Deploy Rich Internet Apps outside the browser with > Adobe(R)AIR(TM) > software. With Adobe AIR, Ajax developers can use existing skills and code > to > build responsive, highly engaging applications that combine the power of > local > resources and data with the reach of the web. Download the Adobe AIR SDK > and > Ajax docs to start building applications today- > http://p.sf.net/sfu/adobe-com > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Oleg B. <ph...@ph...> - 2009-02-03 10:42:58
|
On Mon, Feb 02, 2009 at 09:39:06PM -0500, Stef Telford wrote: > Oleg Broytmann wrote: > > On Mon, Feb 02, 2009 at 03:07:49PM -0500, Stef Telford wrote: > >> alias's will stay 'fixed' at webserver/framework > >> launch .. no ? > > > > Alias counter is increased on every instantiation of Alias(). > > Stupid question here .. but .. why ? (sorry, I know that this could be > a large answer but..) Because SQLObject needs to generate unique alias names and a global counter is the simplest way to do it. Think about joining a table with itself - you need two different names for the table. > Also, whilst I am here, a couple more stupid questions, is there any > flag in the SQLObject which tells me if the object was 'created' from > the database or instantiated from the database/cache ? I ask only > because it would be -awfully- handy to have .. I did look at _creating > but, that's not the right item (obviously) There is no and I really fail to see a difference. Why do you want to distinguish them? > Lastly (I promise) I am thinking of over-riding the _SO_finishCreate > in the SQLObject subclass so that all database inserts go to the > master rather than any slave. I would also have to override > _SO_setValue and set (of course) .. any other methods in SQLObject > that would have to be subclassed ? No, these seem to be enough. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Daniel F. <fet...@go...> - 2009-02-03 02:40:51
|
> So I found SQLObject and SQLAlchemy, > and can't find out from the discussions which is better suited for my > purposes, so I decided to give both a try. It mostly depends on the size and sophistication of your project. For small to mid sized projects sqlobject might be better since it's MUCH easier to use, less verbose, etc. I'm only using sqlobject since my projects are kinda small or mid-sized. Once I gave sqlalchemy a try but it's so complicated and verbose for simple tasks as well that I quickly changed my mind and went back to sqlobject. Apparently sqlalchemy is good for large complex database problems but since I don't have any I don't see any benefit to using sqlalchemy over sqlobject. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Stef T. <st...@um...> - 2009-02-03 02:39:09
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Oleg Broytmann wrote: > On Mon, Feb 02, 2009 at 03:07:49PM -0500, Stef Telford wrote: >> alias's will stay 'fixed' at webserver/framework >> launch .. no ? > > Alias counter is increased on every instantiation of Alias(). > Stupid question here .. but .. why ? (sorry, I know that this could be a large answer but..) Also, whilst I am here, a couple more stupid questions, is there any flag in the SQLObject which tells me if the object was 'created' from the database or instantiated from the database/cache ? I ask only because it would be -awfully- handy to have .. I did look at _creating but, that's not the right item (obviously) Lastly (I promise) I am thinking of over-riding the _SO_finishCreate in the SQLObject subclass so that all database inserts go to the master rather than any slave. I would also have to override _SO_setValue and set (of course) .. any other methods in SQLObject that would have to be subclassed ? Regards Stef -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJh65JANG7uQ+9D9URAjB2AJ9cCoeoKupnZnsFelu3Zt70w729WgCdE/0I rQgn6pwVF3N1p/DG+gAVa+w= =Qnqs -----END PGP SIGNATURE----- |
From: Daniel F. <fet...@go...> - 2009-02-03 02:32:13
|
>> >> By the way, are there plans for a 1.0 release? What are your >> >> requirements for this? >> > >> > There are many plans. I have a rather big TODO for 1.0, 1.1 and even >> > 1.2 > > That's it: Thanks for this Oleg, it's good to know where sqlobject is heading. And it's even better to know that no major issues are there only minor things, at least nothing on your list stands out as extraordinary. This means that sqlobject is already a pretty mature project, even before 1.0. By the way, some weeks ago I decided to switch to sqlalchemy, but after looking at the documentation and some correspondence on the mailing list, I decided not to do it. Sqlobject for my purposes is really great, works perfectly and sqlalchemy seems so super complicated without any obvious gain for my (admittedly, mid-sized) projects. Long live sqlobject! Cheers, Daniel > In dbconnection.py in ConsoleWriter do not save self.logfile in __init__ in > case sys.stdout will be replaced later. > > > Choose SQLite driver: sqlite://...?backend=(sqlite|sqlite3|pysqlite2) > > > alternateMethodName for all unique fields, not only alternateID. > > > tableParamSQL: > > class MyTable(SQLObject): > class sqlmeta: > tableParamSQL = 'ENGINE InnoDB' > tableParamSQL = {'mysql': 'ENGINE InnoDB'} > > > delColumn('foreignKey'), delColumn('foreignKeyID') > > > TimestampCol() - make default=None. > > > Proper %-encoded URI. > > > SET client_encoding for PostgreSQL. > > > IntervalCol. > > > All signal handlers must receive 'self' as the first argument. > > > __version__.py > > > Always use .lazyIter(). > > > Test 'dirty' and other attributes for collisions. > > > Release 1.0. > > > Invert tests 'isinstance(obj, (tuple, list))' to 'not isinstance(obj, > basestr)' > to allow any iterable. > > > More decorators especially @classmethod. > > > Generators instead of loops (fetchall => fetchone). > > > List databases in the connection. > > > List tables in the DB. The query in MySQL is 'SHOW TABLES' > > in SQLite it is > "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name" > > and in Postgres it is something like > "SELECT c.relname FROM pg_class c, pg_type t > WHERE c.reltype = t.oid AND t.typname = 'table'" > > > Release 1.1. > > > Stop supporting Python 2.4: use 'with lock'. > > > Release 1.2. > > > ---------- > > > RelatedJoin.hasOther(otherObject[.id]) > > > .select(), .selectBy() and .by*() must pass the value(s) through > .from_python(); then the hack with UnicodeCol could be removed. > > > Calculated columns - in SELECT but not in INSERT/UPDATE. > Something like this: > > class MyClass(SQLObject): > function1 = CalculatedCol(func.my_function(MyClass.q.col1)) > function2 = CalculatedCol('my_function') > > > All-unicode - one encoding per DB/connection. > > > Optimize Iteration.next() - use cursor.fetchmany(). > > > More documentation. Wiki. Trac. > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Daniel F. <fet...@go...> - 2009-02-03 02:24:46
|
>> >> In newer version of FormEncode compound.All validator got correct >> >> is_empty method: >> >> >> >> def is_empty(self, value): >> >> # sub-validators should handle emptiness. >> >> return False >> >> >> >> So it's time to require more recent FormEncode to be used with >> >> SQLObject. >> > >> > I think it is FormEncode version 1.1.1, but I cannot recommend any >> > version until I run the test suite. >> > >> Great, thanks Oleg! Please let us know when it is safe to upgrade to >> FormEncode 1.2.1. (current version). > > The test suite passed with FormEncode 1.2.1. I added a proper test to > test_validation.py and set the lowest version of FormEncode in setup.py. Thanks a lot Oleg! Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Oleg B. <ph...@ph...> - 2009-02-02 23:04:37
|
On Mon, Feb 02, 2009 at 10:46:42PM +0100, Stef Mientki wrote: > now I think there's a slash too much :-( > Now I wonder, is SQLObject suited for MS-Windows ? My company sells commercial programs for w32; some of these programs use SQLObject pretty heavily. On the server side we use SQLite for small clients and PostgreSQL for bigger ones. Well, we use sqlite:///path/to/data.base syntax with ':' replaced by '|': sqlite:///C|program/data.db. This is how we do it: cwd = os.getcwd() cwd_uri = cwd.replace(os.sep, '/') if os.name == 'nt': cwd_uri = '/' + cwd_uri.replace(':', '|') > ValueError: The table test__create2 ws not found in the database. Load > failed > > Now it's creating an extra underscore ??? No idea. I am sure it is not an SQLObject's error. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Stef M. <ste...@gm...> - 2009-02-02 22:47:05
|
> [skip] > >> "No connection has been defined for this thread " >> AttributeError: No connection has been defined for this thread or process >> > > fromDatabase works at the class creation time and hence requires that > the connection is created before the class is being created: > > sqlhub.processConnection = connectionForURI(...) > class Test_Create2(SQLObject): > ... > > thanks Oleg, that seems to work: but now it complains it can't open the database def makeConnection(self): if self._memory: return self._memoryConn print 'PPPPP',self.filename return sqlite.connect(self.filename, **self._connOptions) prints: PPPPP /D:/Data_Python_25/support/test_vl.db now I think there's a slash too much :-( Now I wonder, is SQLObject suited for MS-Windows ? Ok, let's try a relative path, then it prints PPPPP /test_vl.db still a slash too much I guess, but it does come further : ValueError: The table test__create2 ws not found in the database. Load failed Now it's creating an extra underscore ??? Any suggestions ? thnaks, Stef Mientki |
From: Oleg B. <ph...@ph...> - 2009-02-02 22:38:03
|
On Tue, Jan 27, 2009 at 01:24:18AM -0800, Daniel Fetchinson wrote: > >> By the way, are there plans for a 1.0 release? What are your > >> requirements for this? > > > > There are many plans. I have a rather big TODO for 1.0, 1.1 and even > > 1.2 That's it: In dbconnection.py in ConsoleWriter do not save self.logfile in __init__ in case sys.stdout will be replaced later. Choose SQLite driver: sqlite://...?backend=(sqlite|sqlite3|pysqlite2) alternateMethodName for all unique fields, not only alternateID. tableParamSQL: class MyTable(SQLObject): class sqlmeta: tableParamSQL = 'ENGINE InnoDB' tableParamSQL = {'mysql': 'ENGINE InnoDB'} delColumn('foreignKey'), delColumn('foreignKeyID') TimestampCol() - make default=None. Proper %-encoded URI. SET client_encoding for PostgreSQL. IntervalCol. All signal handlers must receive 'self' as the first argument. __version__.py Always use .lazyIter(). Test 'dirty' and other attributes for collisions. Release 1.0. Invert tests 'isinstance(obj, (tuple, list))' to 'not isinstance(obj, basestr)' to allow any iterable. More decorators especially @classmethod. Generators instead of loops (fetchall => fetchone). List databases in the connection. List tables in the DB. The query in MySQL is 'SHOW TABLES' in SQLite it is "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name" and in Postgres it is something like "SELECT c.relname FROM pg_class c, pg_type t WHERE c.reltype = t.oid AND t.typname = 'table'" Release 1.1. Stop supporting Python 2.4: use 'with lock'. Release 1.2. ---------- RelatedJoin.hasOther(otherObject[.id]) .select(), .selectBy() and .by*() must pass the value(s) through .from_python(); then the hack with UnicodeCol could be removed. Calculated columns - in SELECT but not in INSERT/UPDATE. Something like this: class MyClass(SQLObject): function1 = CalculatedCol(func.my_function(MyClass.q.col1)) function2 = CalculatedCol('my_function') All-unicode - one encoding per DB/connection. Optimize Iteration.next() - use cursor.fetchmany(). More documentation. Wiki. Trac. 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-02 22:32:29
|
On Mon, Jan 26, 2009 at 02:21:51PM -0800, Daniel Fetchinson wrote: > >> In newer version of FormEncode compound.All validator got correct > >> is_empty method: > >> > >> def is_empty(self, value): > >> # sub-validators should handle emptiness. > >> return False > >> > >> So it's time to require more recent FormEncode to be used with > >> SQLObject. > > > > I think it is FormEncode version 1.1.1, but I cannot recommend any > > version until I run the test suite. > > > Great, thanks Oleg! Please let us know when it is safe to upgrade to > FormEncode 1.2.1. (current version). The test suite passed with FormEncode 1.2.1. I added a proper test to test_validation.py and set the lowest version of FormEncode in setup.py. 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-02 21:12:39
|
On Mon, Feb 02, 2009 at 09:55:35PM +0100, Stef Mientki wrote: > I started with SQLObject because in general it's decribed as "easier". Welcome! > So I started here: > > http://www.sqlobject.org/SQLObject.html > > The first problem is that the first example already contains an error ( > at least that's what I guess) > > connection_string = 'sqlite:' + db_filename > > I think there's a slash missing ? Yes. Thank you! > Now the second problem is, > that I want to start with an existing database: > > So this is my code: > > from sqlobject import * > class Test_Create2 ( SQLObject ) : > class sqlmeta : > print 'piep' > fromDatabase = True > > if __name__ == '__main__': > DataBase_Name = 'D:/Data_Python_25/support/test_vl.db' > sqlhub.processConnection = connectionForURI ( 'sqlite:/' + > DataBase_Name ) > Test_Create2.createTable () > > and this the error I get: > Traceback (most recent call last): [skip] > "No connection has been defined for this thread " > AttributeError: No connection has been defined for this thread or process fromDatabase works at the class creation time and hence requires that the connection is created before the class is being created: sqlhub.processConnection = connectionForURI(...) class Test_Create2(SQLObject): ... Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |