我正在寻找javascript函数encodeURIComponent()(http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp)中的等价物,但找不到它。 有谁知道MySQL中是否存在这样的函数?
答案 0 :(得分:0)
import MySQLdb
import urllib
db = MySQLdb.connect(host=" ", # your host, usually localhost
user=" ", # your username
passwd=" ", # your password
db=" ") # your database name
cur = db.cursor()
cur.execute("SELECT column_name FROM table_name")
for row in cur.fetchall():
a = {row[1][:15]:row[1][15:]}
b = urllib.urlencode(a)
print(b)
query="Update table_name set column_name ='" + b + "' where id=" + str(row[0]) +';'
cur.execute(query)
db.commit()
db.close()