在MySQL中,JavaScript的encodeURIcomponent相当于什么?

时间:2015-07-06 04:22:42

标签: mysql encodeuricomponent

我正在寻找javascript函数encodeURIComponent()(http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp)中的等价物,但找不到它。 有谁知道MySQL中是否存在这样的函数?

1 个答案:

答案 0 :(得分:0)

尝试此python代码

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()