473,218 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 software developers and data experts.

sqlite3.OperationalError: Could not decode to UTF-8 column

Hi

I'm trying to use sqlite with python 2.5 but I have this problem:

Traceback (most recent call last):
File "converter.py", line 13, in <module>
c_old.execute('select id_aluno, nome from aluno')
sqlite3.OperationalError: Could not decode to UTF-8 column 'nome' with
text 'Ana Margarida Fernandes Gonçalves de Sá'

The database was created with another program and all data is in
database is in latin1.

Thanks,
Filipe Sousa
Sep 5 '07 #1
2 16712
On Wed, 2007-09-05 at 16:40 +0100, Filipe Sousa wrote:
Hi

I'm trying to use sqlite with python 2.5 but I have this problem:

Traceback (most recent call last):
File "converter.py", line 13, in <module>
c_old.execute('select id_aluno, nome from aluno')
sqlite3.OperationalError: Could not decode to UTF-8 column 'nome' with
text 'Ana Margarida Fernandes Gonçalves de Sá'

The database was created with another program and all data is in
database is in latin1.
Try setting

conn.text_factory = str

where conn is the name of your sqlite3 connection object. See
http://docs.python.org/lib/sqlite3-C...n-Objects.html for more
information.

HTH,

--
Carsten Haese
http://informixdb.sourceforge.net
Sep 5 '07 #2
Carsten Haese wrote:
On Wed, 2007-09-05 at 16:40 +0100, Filipe Sousa wrote:

Try setting

conn.text_factory = str

where conn is the name of your sqlite3 connection object. See
http://docs.python.org/lib/sqlite3-C...n-Objects.html for more
information.

HTH,
Thanks!
It works :)
Sep 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Pratt | last post by:
Recently I have run into an issue with sqlite where I encode strings going into sqlite3 as utf-8. I guess by default sqlite3 is converting this to unicode since when I try to decode I get an...
2
by: aurora | last post by:
I have some unicode string with some characters encode using python notation like '\n' for LF. I need to convert that to the actual LF character. There is a 'unicode_escape' codec that seems to...
2
by: rsd | last post by:
Hi, I'm trying get Samsung YH-920 mp3 player to work with Debian GNU/Linux. To do that I need to run http://www.paul.sladen.org/toys/samsung-yh-925/yh-925-db-0.1.py script, the idea behind the...
38
by: John Salerno | last post by:
Here's my script: import sqlite3 con = sqlite3.connect('labdb') cur = con.cursor() cur.executescript(''' DROP TABLE IF EXISTS Researchers; CREATE TABLE Researchers ( researcherID...
2
by: Josh | last post by:
Hi, I'm running into a problem when trying to create a view in my sqlite database in python. I think its a bug in the sqlite3 api that comes with python 2.5. This works as expected: conn =...
29
by: dbhbarton | last post by:
Had a thought that's grown on me. No idea if it's original or not- too inexperienced in programming- but I guess there's no harm floating it out there. Python wins big on readability, and...
3
by: cjl | last post by:
P: I am using python 2.5.1 on windows. I have the following code: conn = sqlite3.connect('.\optiondata') c = conn.cursor() try: c.execute('''create table options (ssymbol text, strike real,...
2
by: Bob | last post by:
In our database code (we are using django v0.96) we wanted to catch and handle MySQL OperationalErrors. We use both the Django models and database connections. However, even though we confirmed...
1
by: Suwayya | last post by:
db = sqlite3.connect('mydb.db') f1l = f1l = db.execute("SELECT f1 FROM t1").fetchall() for i in range(0,len(f1l)): xmlfile = matchf1(f1l) print xmlfile postcount = 0 for node...
1
by: anonymous | last post by:
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.