jck
jck

Reputation: 2078

What is this extra character python puts before every field in an sql query?

>>> c.execute('select * from zeol').fetchall()
[(u'BBUL1', u'BCF-0106', u'', u'ENVIR', u'2011-01-25', u'18:02:10.92', 
  u'***', u'ALARM', u'', u'', u'33387', u'7401', u'EXTERNAL AL 1', 
  u'SYSTEM ON BATTERY', u''), (u'BBUL1', u'BCF-0106', u'', u'ENVIR', 
  u'2011-01-25', u'18:02:10.92', u'***', u'ALARM', u'', u'', u'33389', 
  u'7401', u'EXTERNAL AL 1', u'SYSTEM ON BATTERY', u''), (u'BBUL1', 
  u'BCF-0106', u'', u'ENVIR', u'2011-01-25', u'18:02:10.93', u'***', u'ALARM',
  u'', u'', u'33389', u'7401', u'EXTERNAL AL 1', u'SYSTEM ON BATTERY', u'')]

all the 'u's are not there in the sqlite database.

Upvotes: 0

Views: 222

Answers (3)

Kyle
Kyle

Reputation: 355

The 'u' prefix indicates the string is unicode. For more information on string encoding/decoding with python, see codecs

Upvotes: 0

zwol
zwol

Reputation: 140856

That's part of the Python syntax for string constants; it means each string constant is a sequence of Unicode codepoints rather than 8-bit bytes. It shows up in the interactive environment because that uses repr to dump complex data structures. It won't show up if you use print or write on individual strings.

Upvotes: 2

Mariy
Mariy

Reputation: 5924

Because that means that this is python unicode string.

Upvotes: 3

Related Questions