I'm using cgi, python 2.7 and sqlite.
I'm trying to insert an string? that contains the characters å,ä and ö into an sqlite table.
the string are taken from an html post using cgi
this code in takes the value:
print '<form action="./printusername.cgi" method="post">'
print 'First Name: <input type="text" name="first_name">'
print '</form>'
im receiving the value in printusername.cgi like this:
import cgi
cgitb.enable()
form = cgi.FieldStorage()
first_name = form.getvalue('first_name')
then i'm trying to pass it to an sqlite table, along whit some other values, like this:
import sqlite3
con = sqlite3.connect('Addressbook.db')
cursor = con.cursor()
contact = (first_name,other_valu_1,other_valu_1)
cursor.execute("INSERT INTO entrys VALUES(?, ?, ?)",contact)
when i'm doing this I'll receive the following error:
<class 'sqlite3.ProgrammingError'>: You must not use 8-bit bytestrings
unless you use a text_factory that can interpret 8-bit bytestrings
(like text_factory = str). It is highly recommended that you instead
just switch your application to Unicode strings.
if I don't use å,ä or ö in the html post everything is working fine.
why is this error occurring? how can i avoid it and still keep the data in the sqlite table readable?.
if the data need to be formated, how can formate it back when 'im accessing it the next time?
all help is appreciated! sry 4 my bad eng.
Aucun commentaire:
Enregistrer un commentaire