[DB-SIG] about module.Binary()
Federico Di Gregorio
fog@mixadlive.com
05 Jun 2001 11:43:26 +0200
just one fast question: does the dbapi require Binary objects to quote
their contents? i.e., is the following code right (assuming postgresql
or any other database that uses ' to enclose strings and that need it to
be quoted)?
>>> import psycopg
>>> bin = psycopg.Binary("this is a string that needs 'quoting'")
>>> print str(bin)
'this is a string that needs ''quoting'''
>>> print repr(bin)
"'this is a string that needs ''quoting'''"
note how the module enclosed the string in ' to allow for:
>>> cursor.execute("INSERT INTO test VALUES (%(str)s)", {'str', bin})
in a more general way, the object returned by a constructor has to
provide the quotes (when requested by the db) or not? for example:
t = psycopg.Date(2001, 7, 5)
print str(t)
should print 2001-07-05 or '2001-07-05'?
enough for now, ciao,
federico
--
Federico Di Gregorio
MIXAD LIVE Chief of Research & Technology fog@mixadlive.com
Debian GNU/Linux Developer & Italian Press Contact fog@debian.org
Debian. The best software from the best people [see above]
-- brought to you by One Line Spam