473,396 Members | 2,013 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,396 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 16758
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.