about escape string store in mysql

ylj798 at gmail.com ylj798 at gmail.com
Sun Nov 16 08:05:49 CET 2008


this string from web by the Regular Expression,
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233"
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
my code:

******************************************************************************
# -*- coding: utf8 -*-
#!/usr/bin/python

import MySQLdb
conn=MySQLdb.connect
(host="localhost",user="root",passwd="ylj",db="net", charset="utf8")
cur = conn.cursor()
s="""href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMDA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ==&233""""
s=mysqldb.escape_string(s)
sql='insert into download(lines) values(%s)'
cur.execute(sql, s)

************************************************************

when I used the mysqldb.escape_string(),but eric gave me a error,tell
me that my sql strings have escape string.
how can i put the strings in database.



More information about the Python-list mailing list