Re: Problems with concatenating strings

Guido.van.Rossum@cwi.nl
Wed, 21 Sep 1994 17:28:39 +0200

> I'm using the python bindings to mSQL to create indexed WWW documents.
> Here's the problem: I can't use lines of text that have quotes.
>
> For instance, here is my statement for writing the title to the database:
> x.Query("update articles set title='"+title+ \
> "' where filename='"+filename+"'")
>
> If title="Configuration options for a cisco router", it gets expanded
> nicely. If title="Configuration options for cisco's new router", it sees
> the ' in cisco's as the termination of the value.
>
> So, how do I handle concatenation when the strings contain arbitrary
> amounts of ' and " symbols?

I can assure you that the Python string concatenation has no problems
with quotes in strings -- in fact it never looks at what's in the
string. Quote interpretation is done by the parser -- Python objects
are arrays of bytes, and don't contain quotes.

>From looking at the relevant routine in msqlmodule.c it seems that
this also doesn't do any quote handling.

Therefore my suspicion is that mSQL itself handles quotes in its
queries. Maybe Anthony Baxter can comment on this?

> It also is giving me problems when I try writing out my HTML.

What exactly happens here? This sounds like a totally unrelated
problem...

--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>