Re: [SQLObject] any Oracle support work?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2005-07-15 16:08:20
|
Oleg Broytmann wrote: > As far as I know Oracle does not allow to pass special values in the > query string. There is no quoting rules. There are no escape characters. > You must pass parametrized query string along with a list of parameters. > E.g., Oracle requires the call > cursor.execute("INSERT INTO atable (field1, field2) VALUES (:p1, :p2)", p1, p2) > SQLObject cannot do that. It currently only able to do > cursor.execute("INSERT INTO atable (field1, field2) VALUES ('%s', '%s')" % (p1, p2)) You can't do it at all? I thought it was just for some types, like BLOB, that there was no textual SQL representation. > A half a year ago I started to work on this - to change the way > SQLObject generates queries. I want to use > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ppa/misc/DBSingleStyle.py?rev=HEAD&content-type=text/vnd.viewcvs-markup) > and generate queries to all databases (including Oracle) using parametrized > strings. I made a very limited progress and stopped. I just don't have > enough time. > I can put my code into the Subversion repository, in a branch, or I can > send you a traball. Hmm... I was just thinking about this, and came up with this: http://svn.colorstudy.com/home/ianb/dbparam_test.py Sadly I can't make it completely backward compatible, because there's no way to make 'column = %s' % self.sqlrepr(foo) create a non-string object, though it would be possible to make 'column = %s' ** self.sqlrepr(foo) work (changing % to **). Still, that's a relatively trivial change all considered. This doesn't make SQLObject use these new classes, but at least they hold all the necessary data. My only concern is with errors (will mismatches in number of parameters not get caught until the SQL is generated), and if it really feels right with more complex queries and extended SQL generation. But then, that's not frequently necessary (even long SQL is usually mostly static). -- Ian Bicking / ia...@co... / http://blog.ianbicking.org |