V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
yingluck
V2EX  ›  问与答

post时数据库出现错误

  •  
  •   yingluck · 2013-11-13 20:33:51 +08:00 · 1868 次点击
    这是一个创建于 3831 天前的主题,其中的信息可能已经有所发展或是发生改变。
    向网站提交数据时网站数据库出错,大概能看出是提交内容格式不正确,但是怎么改却没有头绪,求众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 条回复    1970-01-01 08:00:00 +08:00
    qiayue
        1
    qiayue  
       2013-11-13 20:39:23 +08:00   ❤️ 1
    ('24579','<Storage {'title': u'fg'}>','1384345479','weixin')
    改为
    ('24579','<Storage {"title": "ufg"}>','1384345479','weixin')
    或者
    ('24579','<Storage {\'title\': \'ufg''}>','1384345479','weixin')

    你原文的 u'fg' 我认为是你手误,你本来想写的是 'ufg' 吧?
    qiayue
        2
    qiayue  
       2013-11-13 20:39:57 +08:00
    我也手误了
    或者
    ('24579','<Storage {\'title\': \'ufg\'}>','1384345479','weixin')
    shiny
        3
    shiny  
       2013-11-13 20:41:52 +08:00
    怎么 content 存的这个,先把 python Storage 对象正确转成字符串+转义吧。
    yingluck
        4
    yingluck  
    OP
       2013-11-13 20:55:13 +08:00
    @qiayue 多谢指正!
    yingluck
        5
    yingluck  
    OP
       2013-11-13 20:56:10 +08:00
    @shiny 能详细讲一下吗?python 新手求问!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5545 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 08:11 · PVG 16:11 · LAX 01:11 · JFK 04:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.