MySQL + SQL Statements + Quote escaping

Mark Wilson m.wilson at bibliocraft.com
Sun Feb 11 18:07:39 EST 2001


>Hi there.
>
>i just tuned into python and it's really cool. I like it.
>Before I came to python i used to write scripts in php.
>There was a function called "addslashes" it escaped quotes and
>slashes to make strings sql-safe.
>
>Is there any function like that in python? I didnt found on.

If you're using MySQL from Python, use the MySQL module's escape() function, as
in:

import MySQL

    text_ok_for_sql = MySQL.escape( text_the_user_has_input )

Note there's no reverse procedure necessary with MySQL - text returned from the
database has already been "unescaped".


>Thanks so far.
>
>Christian

Mark






More information about the Python-list mailing list