By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,222 Members | 2,478 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,222 IT Pros & Developers. It's quick & easy.

about escape string store in mysql

P: n/a
this string from web by the Regular Expression,
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMD A4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ== &233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMD A4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ== &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://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMD A4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ== &233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMD A4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ== &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.
Nov 16 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Nov 16, 7:05 am, ylj...@gmail.com wrote:
this string from web by the Regular Expression,
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMD A4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ== &233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMD A4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ== &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://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMD A4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ== &233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yMD A4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ== &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.
The string that you're trying to put into the database ends ...=&233",
so when you triple-quote it you get ...=&233"""". Python sees this
as ...=&233""" (triple quotes end the triple-quoted string) followed
by " and then the end of the line.

Try escaping the quote after ...=&233, ie ...=&233\"""".
Nov 16 '08 #2

P: n/a
MRAB wrote:
On Nov 16, 7:05 am, ylj...@gmail.com wrote:
>this string from web by the Regular Expression,
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yM DA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ= =&233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yM DA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ= =&233"
−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
my code:

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

import MySQLdb
conn=MySQLdb.connect
(host="localhost",user="root",passwd="ylj",db="ne t", charset="utf8")
cur = conn.cursor()
s="""href="#" onClick="ConvertURL2FG('Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yM DA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ= =&233','',
233)" oncontextmenu="Flashget_SetHref(this)" fg="Flashget://
W0ZMQVNIR0VUXWh0dHA6Ly9tb3YuM2dwLmNuL2d1aWxpbi8yM DA4LzExLzExL3l1ZWhvdWppZmVuMDIuM2dwW0ZMQVNIR0VUXQ= =&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.

The string that you're trying to put into the database ends ...=&233",
so when you triple-quote it you get ...=&233"""". Python sees this
as ...=&233""" (triple quotes end the triple-quoted string) followed
by " and then the end of the line.

Try escaping the quote after ...=&233, ie ...=&233\"""".
Or. simpler, use tripled single quotes as your string delimiters.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Nov 16 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.