我在尝试提取存储在 python 中的 sqlite3 数据库中的 utf-8 编码值时遇到问题。
>> import sqlite3
>> connection=sqlite3.connect('mySQLite3DB.db')
>> cursor=connection.cursor()
>> word = unichr(2675)+unichr(37) # ੳ%
>> cursor.execute('select distinct col1 from table1 where col1 like ? limit 3', word)
---------------------------------------------------------------------------
ProgrammingError Traceback (most recent call last)
/Users/punjcoder/code/<ipython-input-10-358f7ffe8df0> in <module>()
----> 1 cursor.execute('select distinct col1 from table1 where col1 like ? limit 3', word)
ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 2 supplied.
现在,如果我通过手动插入 unicode 来运行查询,它就会运行。但是我无法检索文本,而是缓冲 ptr 。
>> cursor.execute('select distinct col1 from table1 where col1 like "ੳ%" limit 3')
<sqlite3.Cursor at 0x10dab8500>
>> for row in cursor.fetchall():
>> print row
(<read-write buffer ptr 0x10dabf898, size 3 at 0x10dabf858>,)
我已经看过下面的链接,但似乎找不到让它工作的方法。我正在研究 Python 2.7.2 和 SQLite 3.7.10。提前感谢您的帮助。