SQL escape sequence problems

Bjorn Pettersen bjorn at roguewave.com
Wed Jan 19 13:04:55 EST 2000


I would probably do:

    sql = "SELECT FROM TABLE WHERE MESSAGEID='%s'" % MySQL.escape(father)

instead, since you really only want to escape the values you are inserting to
the database, and not the sql string itself...

-- bjorn


Asle Pedersen wrote:

> I'm trying to run the following code:
>
> father="something"
> sql="SELECT FROM TABLE WHERE MESSAGEID='%s'" % (father)
> MySQL.escape(sql)
>
> but there is a problem since ' is really an escape character. How can I get
> around this problem? I'm using MySQLmodule-1.2. running under win32
> enviroment. I have tried to get a compiled version of the MySQLdb module
> whithout any success.
>
> regards,
> Asle
>
> --
> http://www.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list