[prev in list] [next in list] [prev in thread] [next in thread]
List: monetdb-developers
Subject: Re: [Monetdb-developers] encoding of strings returned by Python
From: Mark Bucciarelli <mkbucc () gmail ! com>
Date: 2009-12-23 17:24:27
Message-ID: 59f4cb420912230924w42a4a702iadb92aba2c1b79c6 () mail ! gmail ! com
[Download RAW message or body]
On Tue, Dec 22, 2009 at 9:58 AM, Gijs Molenaar <gijs.molenaar@cwi.nl> wrote:
>
> Just committed the REAL/DOUBLE fix, this encoding
> thingy has to wait until January, sorry.
>
One thing I noticed is that the mapi backend has
some magic to handle both Unicode and UTF-8
strings when passed in.
Enlcosed below is the python script I used to
exercise the encoding machinery.
Thanks!
m
import monetdb.sql
from monetdb.monetdb_exceptions import OperationalError
con = monetdb.sql.connect(username="test", password="test", database="test")
c = con.cursor()
try:
c.execute('drop table test')
c.execute('COMMIT')
except OperationalError, e:
c.execute('ROLLBACK')
print "drop table test failed:", e
pass
c.execute('create table test (id int, s varchar(30))')
c.execute('COMMIT')
#
# cafe is in unicode here.
#
cafe = u"caf" + unichr(0x00E9)
print 'cafe.__repr__() =', cafe.__repr__()
print 'cafe.encode("utf8").__repr() =', cafe.encode("utf8").__repr__()
c.execute('insert into test values (%s,%s)', (1,cafe))
#c.execute('insert into test values (%s,%s)', (1,cafe.encode("utf8")))
c.execute('COMMIT')
c.execute("select s from test where id = %d" % (1,))
row = c.fetchone()
print row
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Monetdb-developers mailing list
Monetdb-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/monetdb-developers
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic