sqlobject-discuss Mailing List for SQLObject (Page 365)
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...> - 2004-11-17 16:42:42
|
Hello! I hope I haven't flooded the list too much? On Sat, Nov 13, 2004 at 08:48:21PM +0300, Oleg Broytmann wrote: > from sqlobject.sqlbuilder import Update > from DB import dbConn, Files > update = Update("files", {"filename": "value"}, where=Files.q.filename == "Ocean") > print dbConn.sqlrepr(update) > > => Traceback (most recent call last): > File "test.py", line 5, in ? > print dbConn.sqlrepr(update) > File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 463, in sqlrepr > return sqlrepr(v, self.dbName) > File "/usr/local/lib/python2.3/site-packages/sqlobject/converters.py", line 189, in sqlrepr > return reprFunc(db) > File "/usr/local/lib/python2.3/site-packages/sqlobject/sqlbuilder.py", line 480, in __sqlrepr__ > update += " WHERE %s" % repr(self.whereClause) > File "/usr/local/lib/python2.3/site-packages/sqlobject/sqlbuilder.py", line 155, in __repr__ > return self.__sqlrepr__(None) > File "/usr/local/lib/python2.3/site-packages/sqlobject/sqlbuilder.py", line 222, in __sqlrepr__ > return "(%s %s %s)" % (sqlrepr(self.expr1, db), self.op, sqlrepr(self.expr2, db)) > File "/usr/local/lib/python2.3/site-packages/sqlobject/converters.py", line 187, in sqlrepr > return converter(obj, db) > File "/usr/local/lib/python2.3/site-packages/sqlobject/converters.py", line 98, in StringLikeConverter > assert 0, "Database %s unknown" % db > AssertionError: Database None unknown Found and fixed. the problem is in the line > File "/usr/local/lib/python2.3/site-packages/sqlobject/sqlbuilder.py", line 480, in __sqlrepr__ > update += " WHERE %s" % repr(self.whereClause) It must be update += " WHERE %s" % sqlrepr(self.whereClause, db) Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Leif K-B. <eu...@ec...> - 2004-11-17 09:23:34
|
I'm developing a web web application project which uses SQLObject for the database connection. Everything's working great on my test system; however, looking into the future, I can see that my project will have updates released at some point, some of which will probably involve changes to the database schema. If everyone upgraded straight from version A to version B, it would be very simple: release a script that alters the database along with every version and have the users run it. Unfortunately, some people will end up going from version A straight to version D, which would end up giving them a messed up database schema. How do other people handle upgrades to database schemas gracefully? |
From: Carlos R. <car...@gm...> - 2004-11-16 14:54:03
|
On Tue, 16 Nov 2004 06:11:51 -0800 (PST), Tomas Fulajtar <fu...@ya...> wrote: > The problem here is that intermediate table has > usually no primary key - SQLObject self does not > create any primary key at creation table time. > Therefore you are not able to use this table as class. > That is the reason why it is not possible to use two > One- to many joins as i tried. Or I am wrong? I think > in general intermediate table SHOULD not have primary > key! As far as I know, the reason why its not usual to declare primary keys for a intermediate table is that, in most situations, such table is not used to store any data besides the keys needed for the relationship itself. If you start putting data into it (as it is in your case), then I assume that you should declare it like a normal table; in practical terms, declaring a PK should not be a big deal. You may lose some convenience, but you can model the data correctly. (btw, I think that there is a way to declare that the PK of the intermediate table is a combination of two fields. I don't know if it will work if both fields are FKs though.) -- Carlos Ribeiro Consultoria em Projetos blog: http://rascunhosrotos.blogspot.com blog: http://pythonnotes.blogspot.com mail: car...@gm... mail: car...@ya... |
From: Tomas F. <fu...@ya...> - 2004-11-16 14:11:58
|
--- Ksenia Marasanova <kse...@gm...> wrote: > On Mon, 15 Nov 2004 05:11:48 -0800 (PST), Tomas > Fulajtar > <fu...@ya...> wrote: > > Hi all, > > > > i would like to ask you if could be possible to > acces > > intermediate table column in many to many > > relationship. > > > > For example: > > > > CREATE TABLE person ( > > id SERIAL, > > username VARCHAR(100) NOT NULL UNIQUE > > ); > > > > CREATE TABLE role ( > > id SERIAL, > > name VARCHAR(50) NOT NULL UNIQUE > > ); > > > > CREATE TABLE assigned_roles ( > > person INT NOT NULL, > > role INT NOT NULL, > > assigned_date DATE > > ); > > > > I would like to access the assigned_date column. > Does > > anybody have any idea? In the docs there is > following > > solution, but without using any columns from > > intermediate table. > > > > class Person(SQLObject): > > username = StringCol(length=100, > alternateID=True) > > roles = RelatedJoin('Role', > joinColumn='person', > > otherColumn='role', > > > > intermediateTable='assigned_roles') > > class Role(SQLObject): > > name = StringCol(length=50, alternateID=True) > > roles = RelatedJoin('Person', > joinColumn='role', > > otherColumn='person', > > > > intermediateTable='assigned_roles') > > I think you can define class for assigned_roles, > just like for any > other SQLObject class: > > class AssignedRoles: > person = ForeignKey('Person') > role = ForeignKey('Role') > assignedDate = DateTimeCol() > > > -- > Ksenia > > The problem here is that intermediate table has usually no primary key - SQLObject self does not create any primary key at creation table time. Therefore you are not able to use this table as class. That is the reason why it is not possible to use two One- to many joins as i tried. Or I am wrong? I think in general intermediate table SHOULD not have primary key! Tomas __________________________________ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com |
From: Oleg B. <ph...@ph...> - 2004-11-16 10:36:54
|
On Mon, Nov 15, 2004 at 05:40:39PM +0300, Oleg Broytmann wrote: > I heard rumors that Sybase (and hence MSSQL) will have problems with > two cursors. There is not SybaseConnection yet, but certainly it will > appear sooner or later. Well, this is not just rumor anymore. import adodbapi conn = adodbapi.connect("Provider=sqloledb;SERVER=grad2000;DATABASE=prog3510;UID=sa;PWD=secret;Auto Translate=FALSE") cur1 = conn.cursor() cur2 = conn.cursor() cur1.execute("select 1 union select 2") cur2.execute("select getdate()") Error: Traceback (most recent call last): File "D:\Work\adotest\Debug\test.py", line 7, in ? cur2.execute("select getdate()") File "D:\Python23\lib\site-packages\adodbapi\adodbapi.py", line 592, in execute self.executeHelper(operation,0,parameters) File "D:\Python23\lib\site-packages\adodbapi\adodbapi.py", line 552, in executeHelper self._raiseCursorError(DatabaseError,tracebackhistory) File "D:\Python23\lib\site-packages\adodbapi\adodbapi.py", line 407, in _raiseCursorError eh(self.conn,self,errorclass,errorvalue) File "D:\Python23\lib\site-packages\adodbapi\adodbapi.py", line 38, in standardErrorHandler raise errorclass(errorvalue) adodbapi.adodbapi.DatabaseError: ----------- Strategy 1: Traceback:Traceback (most recent call last): File "D:\Python23\lib\site-packages\adodbapi\adodbapi.py", line 540, in executeHelper adoRetVal=self.cmd.Execute() File "D:\Python23\lib\site-packages\win32com\gen_py\EF53050B-882E-4776-B643-EDA472E8E3F2x0x2x7.py", line 1845, in Execute return self._ApplyTypes_(5, 1, (9, 0), ((16396, 18), (16396, 17), (3, 49)), 'Execute', '{00000556-0000-0010-8000-00AA006D2EA4}',RecordsAffected, Parameters, Options) File "D:\Python23\lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_(com_error: (-2147352567, 'Exception occurred.', (0, 'Microsoft OLE DB Provider for SQL Server', 'Cannot create new connection because in manual or distributed transaction mode.', None, 0, -2147467259), None) Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Martin d'A. <Mar...@s2...> - 2004-11-16 06:56:28
|
On Mon, 15 Nov 2004, Martin d'Anjou wrote: > Hi, > > I have this code where I want to pre-define classes for the tables, and > connect them at run time to the database, but it does not work. Here is > the code: > > #!/usr/bin/env python > > from sqlobject import * > > class Person(SQLObject): > # Connection always defined at runtime > name = StringCol(length=255,default=None) > > def main(db_name): > conn = connectionForURI('mysql://user:passwd@server/'+db_name) > trans = conn.transaction > Person.createTable(trans) > > if __name__ == '__main__': > main('test') > > % ./simple.py > Traceback (most recent call last): > File "./simple.py", line 15, in ? > main('yo') > File "./simple.py", line 12, in main > Person.createTable(trans) > File "/usr/local/lib/python2.3/site-packages/sqlobject/main.py", > line 973, in createTable > if ifNotExists and cls._connection.tableExists(cls._table): > AttributeError: 'NoneType' object has no attribute 'tableExists' > I found a solution: class Person(SQLObject): # Connection always defined at runtime name = StringCol(length=255,default=None) def main(db_name): conn = connectionForURI('mysql://user:passwd@server/'+db_name) Person._connection = conn Person.createTable(ifNotExists=True) if __name__ == '__main__': main('test') And it works. Martin |
From: Martin d'A. <Mar...@s2...> - 2004-11-16 02:05:39
|
Hi, I have this code where I want to pre-define classes for the tables, and connect them at run time to the database, but it does not work. Here is the code: #!/usr/bin/env python from sqlobject import * class Person(SQLObject): # Connection always defined at runtime name = StringCol(length=255,default=None) def main(db_name): conn = connectionForURI('mysql://user:passwd@server/'+db_name) trans = conn.transaction Person.createTable(trans) if __name__ == '__main__': main('test') % ./simple.py Traceback (most recent call last): File "./simple.py", line 15, in ? main('yo') File "./simple.py", line 12, in main Person.createTable(trans) File "/usr/local/lib/python2.3/site-packages/sqlobject/main.py", line 973, in createTable if ifNotExists and cls._connection.tableExists(cls._table): AttributeError: 'NoneType' object has no attribute 'tableExists' I am sure I am making a mistake... can someone help please? Thanks, Martin |
From: Oleg B. <ph...@ph...> - 2004-11-15 18:17:00
|
Hello! Attached is a Daniel Savard's inheritance patch adapted to SQLObject 0.6.1 by my colleagues Alexander Smishlajev, Yaroslav Samchuk and me. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Nick <ni...@dd...> - 2004-11-15 17:01:04
|
Ian Bicking wrote: > Hmm... unfortunately I can't think of any way of indicating the current > directory in a fully qualified URI. Does anyone have ideas? > sqlite:/:pwd:/file.db ? To be a proper URI, my guess would be sqlite:.%2Ffile.db Nick |
From: Ian B. <ia...@co...> - 2004-11-15 16:47:54
|
Brian Beck wrote: > Ian Bicking <ianb <at> colorstudy.com> writes: > > >>>Maybe I'm wrong, but the URI format doesn't seem very win32 friendly. >> >>How so? Forward slashes can always replace backslashes for paths (and >>even that only applies to SQLite and Firebird, since the other databases >>don't use file paths anywhere). >> > > > On Win32 for SQLite, I can only use sqlite:/file.db or sqlite:///file.db, Right, because there's no server for SQLite, so there's no remote host possible. > AND > this creates the file in the ROOT directory of whatever drive the script is > running from, NOT the path of the script! This is highly undesirable. Hmm... unfortunately I can't think of any way of indicating the current directory in a fully qualified URI. Does anyone have ideas? sqlite:/:pwd:/file.db ? -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
From: Oleg B. <ph...@ma...> - 2004-11-15 15:25:04
|
Oops, followup to myself. On Mon, Nov 15, 2004 at 05:40:39PM +0300, Oleg Broytmann wrote: > Another cursor is created in the same connection while the first one > is still being iterated. Is it correct? Some DB API adapters allows it. > For example MySQLdb emulates cursors by copying all data. But what about > other adapters and databases? For every complex problem, there is a solution that is simple, neat, and wrong. Actuall, I can see two simple solutions. 1. Open another connection. Very bad for transactions. 2. Use cursor.fetchall() instead of .fetchone(). Very bad for huge data set. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Ksenia M. <kse...@gm...> - 2004-11-15 14:57:57
|
On Mon, 15 Nov 2004 05:11:48 -0800 (PST), Tomas Fulajtar <fu...@ya...> wrote: > Hi all, > > i would like to ask you if could be possible to acces > intermediate table column in many to many > relationship. > > For example: > > CREATE TABLE person ( > id SERIAL, > username VARCHAR(100) NOT NULL UNIQUE > ); > > CREATE TABLE role ( > id SERIAL, > name VARCHAR(50) NOT NULL UNIQUE > ); > > CREATE TABLE assigned_roles ( > person INT NOT NULL, > role INT NOT NULL, > assigned_date DATE > ); > > I would like to access the assigned_date column. Does > anybody have any idea? In the docs there is following > solution, but without using any columns from > intermediate table. > > class Person(SQLObject): > username = StringCol(length=100, alternateID=True) > roles = RelatedJoin('Role', joinColumn='person', > otherColumn='role', > > intermediateTable='assigned_roles') > class Role(SQLObject): > name = StringCol(length=50, alternateID=True) > roles = RelatedJoin('Person', joinColumn='role', > otherColumn='person', > > intermediateTable='assigned_roles') I think you can define class for assigned_roles, just like for any other SQLObject class: class AssignedRoles: person = ForeignKey('Person') role = ForeignKey('Role') assignedDate = DateTimeCol() -- Ksenia |
From: Oleg B. <ph...@ph...> - 2004-11-15 14:40:43
|
Hello! atable.select(... lazyColumns=True ...) pases lazyColumns to SelectResults(), that passes it (in self.__iter__) to dbconnection.Iteration(), whose .next() method creates an object by calling self.select.sourceClass.get(), and the .get() calls val._init() that seeing no selectResults in its turn calls self._connection._SO_selectOne() that creates another cursor to fetch the data. Another cursor is created in the same connection while the first one is still being iterated. Is it correct? Some DB API adapters allows it. For example MySQLdb emulates cursors by copying all data. But what about other adapters and databases? I heard rumors that Sybase (and hence MSSQL) will have problems with two cursors. There is not SybaseConnection yet, but certainly it will appear sooner or later. The situation becomes even worse with Danila Savard's inheritance patch, because parent's .get() fetches a child calling .get() without selectResults even if lazyColumns=False. Any thoughts? Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Tomas F. <fu...@ya...> - 2004-11-15 13:11:56
|
Hi all, i would like to ask you if could be possible to acces intermediate table column in many to many relationship. For example: CREATE TABLE person ( id SERIAL, username VARCHAR(100) NOT NULL UNIQUE ); CREATE TABLE role ( id SERIAL, name VARCHAR(50) NOT NULL UNIQUE ); CREATE TABLE assigned_roles ( person INT NOT NULL, role INT NOT NULL, assigned_date DATE ); I would like to access the assigned_date column. Does anybody have any idea? In the docs there is following solution, but without using any columns from intermediate table. class Person(SQLObject): username = StringCol(length=100, alternateID=True) roles = RelatedJoin('Role', joinColumn='person', otherColumn='role', intermediateTable='assigned_roles') class Role(SQLObject): name = StringCol(length=50, alternateID=True) roles = RelatedJoin('Person', joinColumn='role', otherColumn='person', intermediateTable='assigned_roles') Thanks for ideas Tomas __________________________________ Do you Yahoo!? Check out the new Yahoo! Front Page. www.yahoo.com |
From: Oleg B. <ph...@ph...> - 2004-11-15 10:41:17
|
Hello. Bug: def coerceID(cls, value): if isinstance(value, cls): return value.id else: return self._idType(value) ^^^^ | s/self/cls/ -----+ Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Brian B. <ex...@gm...> - 2004-11-15 04:40:38
|
Ian Bicking <ianb <at> colorstudy.com> writes: > > Maybe I'm wrong, but the URI format doesn't seem very win32 friendly. > > How so? Forward slashes can always replace backslashes for paths (and > even that only applies to SQLite and Firebird, since the other databases > don't use file paths anywhere). > On Win32 for SQLite, I can only use sqlite:/file.db or sqlite:///file.db, AND this creates the file in the ROOT directory of whatever drive the script is running from, NOT the path of the script! This is highly undesirable. Brian |
From: Charles B. <li...@st...> - 2004-11-13 19:08:41
|
> Now I'm facing the same problem with SQLObject (using psycopg driver). > Before digging into the driver code, I wanted to ask -- am I correct > that there is no commit() after select? Is there a simple way to > implement it? I was under the impression that commits happen automatically under SQLObject, unless you are using transactions. However, since you mentioned multiple processes, I have run into problems where a SQLObject cache in one process will not know that a commit has occurred and will show the cached (stale) object instead. To get around this in Quixote I expire all SQLObject caches at the end of every request. I'm not sure if the high level function to do this has been fixed in recent code. I use the following custom function which seems to get the job done. def flush_conn(conn): """ accepts a DBConnection object and cycles through and expires all cached items """ for key in conn.cache.caches.keys(): for id in conn.cache.caches[key].allIDs(): conn.cache.caches[key].expire(id) Maybe thats not it at all though.... -Charles. |
From: Oleg B. <ph...@ph...> - 2004-11-13 17:48:30
|
Hi! from sqlobject.sqlbuilder import Delete from DB import dbConn, Files delete = Delete("files", where=Files.q.filename == "Ocean") print dbConn.sqlrepr(delete) => DELETE FROM files WHERE (files.filename = 'Ocean') Ok. from sqlobject.sqlbuilder import Update from DB import dbConn, Files update = Update("files", {"filename": "value"}, where=Files.q.filename == "Ocean") print dbConn.sqlrepr(update) => Traceback (most recent call last): File "test.py", line 5, in ? print dbConn.sqlrepr(update) File "/usr/local/lib/python2.3/site-packages/sqlobject/dbconnection.py", line 463, in sqlrepr return sqlrepr(v, self.dbName) File "/usr/local/lib/python2.3/site-packages/sqlobject/converters.py", line 189, in sqlrepr return reprFunc(db) File "/usr/local/lib/python2.3/site-packages/sqlobject/sqlbuilder.py", line 480, in __sqlrepr__ update += " WHERE %s" % repr(self.whereClause) File "/usr/local/lib/python2.3/site-packages/sqlobject/sqlbuilder.py", line 155, in __repr__ return self.__sqlrepr__(None) File "/usr/local/lib/python2.3/site-packages/sqlobject/sqlbuilder.py", line 222, in __sqlrepr__ return "(%s %s %s)" % (sqlrepr(self.expr1, db), self.op, sqlrepr(self.expr2, db)) File "/usr/local/lib/python2.3/site-packages/sqlobject/converters.py", line 187, in sqlrepr return converter(obj, db) File "/usr/local/lib/python2.3/site-packages/sqlobject/converters.py", line 98, in StringLikeConverter assert 0, "Database %s unknown" % db AssertionError: Database None unknown Ouch! Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2004-11-13 17:39:13
|
Hello, Ian! >>> from DB import dbConn 1/Pool : ACQUIRE pool=[] >>> from sqlobject.sqlbuilder import Insert >>> insert = Insert("table", values={"name": "val'ue"}) >>> dbConn.sqlrepr(insert) "INSERT INTO table (name) VALUES ('val''ue')" Oops, that's wrong. Like in _likeQuote. MySQL and Postgres use \' to quote apostrophe, not ''. converters.sqlStringReplace[1] = ("'", "\\'") (at least for Postgres and MySQL). Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Ksenia M. <kse...@gm...> - 2004-11-13 09:44:37
|
Hi, Some time ago I had a problem with psycopg and Quixote - the database changes made by one Quixote process were not visible to the other one. I solved it by using connection.commit() after each SELECT statement. Now I'm facing the same problem with SQLObject (using psycopg driver). Before digging into the driver code, I wanted to ask -- am I correct that there is no commit() after select? Is there a simple way to implement it? Thanks! -- Ksenia |
From: Michel T. S. <mic...@ya...> - 2004-11-12 22:19:22
|
Sorry guys, I sent the message to wrong list, really sorry... -- Michel Thadeu Sabchuk Curitiba/PR |
From: Erika J. <dvk...@ti...> - 2004-11-12 12:30:03
|
show liked worthy grabbed else human money nine seize stop swimming |
From: Michel T. <mic...@ya...> - 2004-11-12 03:31:11
|
Hi guys! Ian, after the recent thread about form validation I think to try FormEncode, I used and still use FunFormKit for my projects, I use the FFK form generation and I confess it limitates my possibilities. I like the way htmlfill work, I tried to make a validator to a form with sucess, my only problem was when I try to use htmlfill. I will put my code on the end of message. I must question you that are using FormEncode with Webware, what is the best way to work with the two packages? I think in a way: First I will check for errors in the writeHTML method, if the form was processed and there is an error, I will define an attribute with this error. If there is no error, I can call a formProcessed function... Then I should write the content of the page, the form is part of the page (using self.write to write it). I want to trigger the page writing, I want to get the content before write and then parse it with htmlfill, filling default values and error messages. Does anyone know how can I trigger the page writing? I use a subclass of the Cheetah's Template, not Page. Sorry any english mistake, my htmlfill try are the follow: #:: FormEncode test... from validator.schema import Schema from validator import validators from validator import htmlfill class MyValidator(Schema): name=validators.String(not_empty=True) age=validators.Int() form='''\ <form method="post"> <table> <tr> <td>Name: <form:error name="name"></td><td><input type="text" name="name"></td> <form:iferror name="name">mndfnaofdas</form:iferror> </tr> <p><input type="submit" name="_action_send" value="Send Data"></p> </form>''' userInput={'name':'michel', 'age':20} errorDict={} try: userInput=validators.to_python(MyValidator, userInput) except validators.Invalid, error: errorDict=error.error_dict parser=htmlfill.FillingParser(userInput, errors=errorDict) parser.feed(form) print parser.text() parser.close() ... I get the follow error: Traceback (most recent call last): File "teste.py", line 29, in ? parser.feed(form) File "/usr/lib/python2.3/site-packages/validator/htmlfill.py", line 68, in feed HTMLParser.HTMLParser.feed(self, data) File "/usr/lib/python2.3/HTMLParser.py", line 108, in feed self.goahead(0) File "/usr/lib/python2.3/HTMLParser.py", line 150, in goahead k = self.parse_endtag(i) File "/usr/lib/python2.3/HTMLParser.py", line 329, in parse_endtag self.handle_endtag(tag.lower()) File "/usr/lib/python2.3/site-packages/validator/htmlfill.py", line 127, in handle_endtag self.handle_end_iferror() TypeError: handle_end_iferror() takes exactly 2 arguments (1 given) Thanks for any help! ===== -- Michel Thadeu Sabchuk Curitiba/PR _______________________________________________________ Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora! http://br.acesso.yahoo.com/ |
From: Ian B. <ia...@co...> - 2004-11-10 16:46:03
|
Luke Opperman wrote: > Your question brings another one to mind, about additional criteria on the > select used for joins (both RelatedJoin and MultipleJoin). Using your > relationships: > > All children addresses with zipcode '98661' > All parent addresses in the same city as the current record. > > I know I've mentioned this before, so this is more a reminder to myself - I > keep finding reasons for this, but it's easy enough to work around, just a > duplication of knowledge about what the joinColumns names are. > > It needs to take at least a query argument, and should probably take > most of > the select() arguments. Either an additional public method > (joinMethodNameSelect perhaps) or an internal method of the join (which > would > need a better way to retrieve join objects - > self._joinNames['joinMethodName'].select perhaps). Yes, that seems reasonable. Off the top of my head, I'm guessing it could almost be like: def childrenSelect(self, query, **kw): query = query & (self.id == ChildTable.q.thisID) return ChildTable.select(query, **kw) Obviously generalized some, so that it allows for string queries and all the other join options. Joins need to be cleaned up some too, so a general refactoring might be good. Another option for joins was to make them live lists, so that appending or removing changed the underlying database. I'm thinking that might be unnecessarily clever, though, and building it on a select would be better. -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |
From: Ksenia M. <kse...@gm...> - 2004-11-10 15:12:53
|
Thanks a lot to all of you for the help, That's a lot of information to study for novice SQLObject user :) I am not sure I follow everything Luke explained about the joins , but it will come... I apologize, my question was very unclear. Yes, I only need direct children (no need for hierarchical SQL lookups at the moment). But I also want to search children, like the examples Luke has given. I was reading the documentation about select() method and wanted to use it for searching. Like in this example: peeps = Person.select( AND(Address.q.personID == Person.q.id, Address.q.zip.startswith('504'))) ...but for RelatedJoin. But I see now that with custom methods and by overriding SQLObject methods there are more possibilities.... Ksenia. P.S. Here is the current code, just in case: class AddressParentChild(SQLObject): child = ForeignKey('Address', cascade=True) parent = ForeignKey('Address', cascade=True) class Address(SQLObject): name = StringCol(length=200) email = StringCol(length=100) type = StringCol(length=100, default='person') parents = RelatedJoin("Address", addRemoveName="Parent", intermediateTable="address_parent_child", otherColumn = "parent_id", joinColumn="child_id") children = RelatedJoin("Address", addRemoveName="Child", intermediateTable="address_parent_child", otherColumn= "child_id", joinColumn="parent_id") and the hard coded SQL I use now that should be changed (in this example to find children with name X or children whoes parent has name X) rows = Address.select(''' (address.id IN (SELECT child_id FROM address_parent_child INNER JOIN address ON address_parent_child.parent_id = address.id WHERE address.name ILIKE %s)) OR (address.name ILIKE %s) ''' % (Address.sqlrepr('%' + selected_parent + '%'), Address.sqlrepr('%' + selected_parent + '%')), orderBy=Address.q.name) |