Note that there are some explanatory texts on larger screens.

plurals
  1. POQuerying and extracting a Unicode value from sqlite3 in Python
    primarykey
    data
    text
    <p>I'm having issues trying to extract utf-8 encoded values stored in an sqlite3 database in python. </p> <pre><code>&gt;&gt; import sqlite3 &gt;&gt; connection=sqlite3.connect('mySQLite3DB.db') &gt;&gt; cursor=connection.cursor() &gt;&gt; word = unichr(2675)+unichr(37) # ੳ% &gt;&gt; cursor.execute('select distinct col1 from table1 where col1 like ? limit 3', word) --------------------------------------------------------------------------- ProgrammingError Traceback (most recent call last) /Users/punjcoder/code/&lt;ipython-input-10-358f7ffe8df0&gt; in &lt;module&gt;() ----&gt; 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. </code></pre> <p>Now if I run the query by manually inserting the unicode, it runs. However I'm not able to retrieve the text, but buffer ptr instead.</p> <pre><code>&gt;&gt; cursor.execute('select distinct col1 from table1 where col1 like "ੳ%" limit 3') &lt;sqlite3.Cursor at 0x10dab8500&gt; &gt;&gt; for row in cursor.fetchall(): &gt;&gt; print row (&lt;read-write buffer ptr 0x10dabf898, size 3 at 0x10dabf858&gt;,) </code></pre> <p>I have alread seen the links below, however can't seem to find a way to make it work. I'm working on Python 2.7.2 and SQLite 3.7.10. Your help is appreciated in advance.</p> <ul> <li><a href="https://stackoverflow.com/questions/9162701/extracting-values-from-sqlite-database-in-python">Extracting values from SQLite database in Python</a></li> <li><a href="https://stackoverflow.com/questions/2392732/sqlite-python-unicode-and-non-utf-data">SQLite, python, unicode, and non-utf data</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload