Gadfly: single-quote in varchar?
Richard Jones
rjones at ekit-inc.com
Wed May 22 18:45:03 EDT 2002
On Thu, 23 May 2002 03:50, Sam Penrose wrote:
> I cannot get Gadfly to INSERT a string containing a single-quote (')
> into a VARCHAR field. Gadfly appears to insist that strings passed to
>
> its parsing framework be delimited with single quotes:
> >>> cursor.execute("INSERT INTO t (Description) VALUES ('alpha')")
>
> NOT
>
> >>> cursor.execute('INSERT INTO t (Description) VALUES ("alpha")')
>
> which may or may not be connected, (and rules out the obvious 'INSERT
> INTO t (Description) VALUES ("alpha's before beta")') but at any rate no
> variation on
>
> >>> cursor.execute("INSERT INTO t (Description) VALUES ('alpha\'s before
>
> beta')")
>
> >>> cursor.execute("INSERT INTO t (Description) VALUES ('alpha\\'s
>
> before beta')")
>
> >>> cursor.execute("INSERT INTO t (Description) VALUES ('alpha\\\'s
>
> before beta')")
>From the gadfly documentation (sql.html -> "Expressions"):
String constants are set off by apostrophies, where two apostrophe's in
sequence represent an apostrophy in the string:
'SQL string literals ain''t pretty'
Also, if the data is dynamic you're almost always better off using a dynamic
data statement. That way all data quoting is handled for you. Again in the
Expressions chapter:
The Dynamic expression "?" is a placeholder for a value bound at evaluation
time (from Python values).
Sadly the crossreference is no good (being fixed) but the info is in
gadfly.html -> Dynamic Values.
> seems to work, although some fail silently, neither raising an error or
> inserting the row.
This sounds like a bug. Please submit bugs to the gadfly bug tracker.
Richard
More information about the Python-list
mailing list