yingluck
V2EX  ›  问与答

post时数据库出现错误

  •  
  •   yingluck · Nov 13, 2013 · 2543 views
    This topic created in 4765 days ago, the information mentioned may be changed or developed.
    向网站提交数据时网站数据库出错,大概能看出是提交内容格式不正确,但是怎么改却没有头绪,求众V2EXer帮忙
    INSERT INTO et_content (user_id,content_body,posttime,type) VALUES ('24579','<Storage {'title': u'fg'}>','1384345479','weixin') Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'title': u'fg'}>','1384345479','weixin')' at line 1
    5 replies  •  1970-01-01 08:00:00 +08:00
    qiayue
    qiayue
    Nov 13, 2013❤️1
    1
    ('24579','<Storage {'title': u'fg'}>','1384345479','weixin')
    改为
    ('24579','<Storage {"title": "ufg"}>','1384345479','weixin')
    或者
    ('24579','<Storage {\'title\': \'ufg''}>','1384345479','weixin')

    你原文的 u'fg' 我认为是你手误,你本来想写的是 'ufg' 吧?
    qiayue
    qiayue
    Nov 13, 2013
    2
    我也手误了
    或者
    ('24579','<Storage {\'title\': \'ufg\'}>','1384345479','weixin')
    shiny
    shiny
    Nov 13, 2013
    3
    怎么 content 存的这个,先把 python Storage 对象正确转成字符串+转义吧。
    yingluck
    yingluck
    OP
    Nov 13, 2013
    4
    @qiayue 多谢指正!
    yingluck
    yingluck
    OP
    Nov 13, 2013
    5
    @shiny 能详细讲一下吗?python 新手求问!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2084 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 00:23 · PVG 08:23 · LAX 16:23 · JFK 19:23
    ♥ Do have faith in what you're doing.