Python中文
首页
教程
问答
标签
搜索
登录
注册
psycopg2“TypeError:不是所有在字符串格式化期间转换的参数”
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>我试图将二进制数据(惠而浦散列)插入到PG表中,得到一个错误:</p> <pre><code>TypeError: not all arguments converted during string formatting </code></pre> <p>代码:</p> <pre><code>cur.execute(""" INSERT INTO sessions (identity_hash, posted_on) VALUES (%s, NOW()) """, identity_hash) </code></pre> <p>我尝试在插入之前将conn.Binary(“identity_hash”)添加到变量中,但得到了相同的错误。</p> <p>identity_hash列是一个bytea。</p> <p>有什么想法吗?</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>问题是,您将对象作为第二个参数传递:第二个参数应该是元组或dict。没有%string运算符中的快捷方式。</p> <p>你应该:</p> <pre><code>cur.execute(""" INSERT INTO sessions (identity_hash, posted_on) VALUES (%s, NOW()) """, (identity_hash,)) </code></pre>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
Python猜字gam
2 回答
Python猜字游戏
7 回答
Python猜字游戏?
1 回答
Python猜字游戏不会在玩家猜测所有字母时结束
7 回答
Python猜字游戏在有重复字符的单词上失败
9 回答
Python猜想
3 回答
Python猜数字游戏,而循环没有响应
3 回答
python猜测gam的代码反馈
7 回答
python猜测gam的变量问题
1 回答
python猜测具体路径?
6 回答
Python猜测我的号码(反向号码猜测)UnboundLocalE
2 回答
python猜测该数字在猜测过度后再试一次
10 回答
Python猜猜单词游戏bug
6 回答
Python猜猜游戏如何再现
2 回答
Python猜猜游戏服务器
3 回答
Python猜猜谁的游戏我没有得到我预期的输出
3 回答
Python猜谜游戏
3 回答
Python猜谜游戏,值错误:randrange()的空范围
5 回答
Python猜谜游戏,带尝试选项
8 回答
Python猜谜游戏,我的赢的条件打印赢和输
10 回答