By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,922 Members | 1,928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,922 IT Pros & Developers. It's quick & easy.

sqlite3 decode error

P: n/a
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 attribute error
like this:

AttributeError: 'unicode' object has no attribute 'decode'

The code and data I am preparing is to work on postgres as well a
sqlite so there are a couple of things I could do. I could always
store any data as unicode to any db, or test the data to determine
whether it is a string or unicode type when it comes out of the
database so I can deal with this possibility without errors. I will
likely take the first option but I looking for a simple test to
determine my object type.

if I do:
type('maybe string or maybe unicode')
I get this:
<type 'unicode'>

I am looking for something that I can use in a comparison.

How do I get the type as a string for comparison so I can do something

if type(some_data) == 'unicode':
do some stuff
do something else


Nov 8 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.