Gadfly: single-quote in varchar?

Scherer, Bill Bill.Scherer at VerizonWireless.com
Wed May 22 13:59:17 EDT 2002


On Wed, 22 May 2002, 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:

In Oracle anyway, one proper way of doing this is to double the 
single quote, eg:
cursor.execute("INSERT INTO t (Description) VALUES ('alpha''s 
before beta')")

I don't know how Gadfly will react to that, but it wasn't in your 
list of tried-out-things, so give it a go.


> 
>  >>> 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')")
> 
> seems to work, although some fail silently, neither raising an error or 
> inserting the row. Description has been defined as a VARCHAR field and 
> happily accepts strings with other punctuation, including double-quotes. 
> Anyone know if this is a Gadfly constraint, or notice some dunderheaded 
> mistake I'm making?
> 
> Gadfly 1.0.0rc1, Unix python 2.2 on Mac OS X.
> 
> TIA,
> Sam
> 
> 
> 
> 

-- 
Bill.Scherer at Verizon Wireless
RHCE 807101044903581






More information about the Python-list mailing list