On 15 February 2011 08:49, hywang <why00...@163.com> wrote: > Please help to run it :-) > > # File Name: default.py > > def index(): > db.define_table("pymysql",Field("content","text"),migrate=True) > content = """'http://img1.t.sinajs.cn/t3/style/css/common/ > layer.css'""" > #content = """this sentence is no problem at all""" > db.executesql("INSERT INTO pymysql (content)VALUES(%s)",content) > return dict() > > > content = """'http://img1.t.sinajs.cn/t3/style/css/common/ ...: layer.css'"""
In [2]: content Out[2]: "'http://img1.t.sinajs.cn/t3/style/css/common/\nlayer.css'" In [3]: query = "INSERT INTO pymysql (content)VALUES(%s)",content In [4]: query Out[4]: ('INSERT INTO pymysql (content)VALUES(%s)', "'http://img1.t.sinajs.cn/t3/style/css/common/\nlayer.css'") In [5]: query = "INSERT INTO pymysql (content)VALUES(%s)" % content In [6]: query Out[6]: "INSERT INTO pymysql (content)VALUES(' http://img1.t.sinajs.cn/t3/style/css/common/\nlayer.css')" You syntax is incorrect as showed in [3]. The correct query[6] is generated by the syntax in [5]. Regards Johann -- May grace and peace be yours in abundance through the full knowledge of God and of Jesus our Lord! His divine power has given us everything we need for life and godliness through the full knowledge of the one who called us by his own glory and excellence. 2 Pet. 1:2b,3a