python 2.7.12 on Linux behaving differently than on Windows

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun Dec 4 18:06:41 EST 2016


Steve D'Aprano wrote:
> On Mon, 5 Dec 2016 07:26 am, DFS wrote:
> 
>> no such column: R
> 
> doesn't this mean that your column is called:
> 
> single quote R single quote

I think he intends it to be an SQL string literal (which uses
single quotes), but since the quotes disappeared, SQL is trying
to interpret it as a column name.

>>Edit: I got it to work this way:
>>column2="'R'"
>>
>>but that's bogus, and I don't want users to have to do that.

DFS: Is the argument always going to be a literal, or could
the user sometimes want to pass a column name?

If it's always a literal, your program could add the quotes
before passing it to SQL.

If it's not always a literal, you'll just have to deal with
the fact that the unix shell is a programming language that
has its own interpretation of quotes. Either the user will
have to escape the quotes, or you'll have to provide another
way of distinguishing literals from column names.

-- 
Greg


More information about the Python-list mailing list