socketref,再见!高德

https://github.com/adoggie

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  246 Posts :: 4 Stories :: 312 Comments :: 0 Trackbacks

常用链接

留言簿(54)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

名字很滑稽,使用方法与 pgsql for python使用方式有所不同 ,但都 遵循DB2.0

http://initd.org/psycopg/docs/usage.html 参考文档


>>> cur.execute("INSERT INTO foo VALUES (%s)", ("bar",)) # correct
注意 %s不能携带''字符串定界符;参数tuples必须添加末尾 ,

>>> cur.execute(
... """INSERT INTO some_table (an_int, a_date, a_string)
... VALUES (%s, %s, %s);""",
... (10, datetime.date(2005, 11, 18), "O'Reilly"))
参数数组传递方式

>>> cur.execute(
... """INSERT INTO some_table (an_int, a_date, another_date, a_string)
... VALUES (%(int)s, %(date)s, %(date)s, %(str)s);""",
... {'int': 10, 'str': "O'Reilly", 'date': datetime.date(2005, 11, 18)})
参数哈希传递方式

cur.execute('insert into table_a values(%s)',(psycopg2.Binary(file.read()),))
插入二进制数据



posted on 2010-04-18 01:11 放屁阿狗 阅读(778) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理