inbetween cPickle and MySQL

Kevin Dahlhausen kdahlhaus at yahoo.com
Wed May 29 16:54:28 EDT 2002


I was referring to the wrapper I placed on NCCW, not
on sf.  Did you spin the SF one off of the NCCW
one?Glad that you are putting the effort into an
improved wrapper. I've not been able to do anything to
mine in a while.


--- Gerhard Häring <gerhard at bigfoot.de> wrote:
> * Kevin Dahlhausen <kdahlhaus at yahoo.com> [2002-05-29
> 11:36 -0700]:
> > m2 at plusseven.com wrote in message
>
news:<mailman.1022665786.12266.python-list at python.org>...
> > > I need a simple way to store lots of simple
> objects (compsed of
> > > strings only). Right now I'm using cPickle,
> which means I have to read
> > > in the intire file to find all object.attribute>
== X. 
> > 
> > There is a python inteface to Sqlite, which is a
> file-based SQL
> > database.  You use the module, no server is needed
> and it does not
> > load the entire file into memory.
> 
> Yes, such a module is available at
> http://pysqlite.sf.net/
> 
> > Currently it returns all results as strings.
> 
> Not true for the CVS version of the _above_
> PySQLite. You _can_ use
> custom converters, and int, float and string are
> supported by default.
> It requires some magic because SQLite is typeless,
> this should show the
> features for people familiar with the DB-API:
> 
> >>> import sqlite
> >>> db = sqlite.connect("/tmp/db")
> >>> cursor = db.cursor()
> >>> cursor.execute("create table test(id int, name
> varchar(20))")
> >>> cursor.execute("insert into test(id, name)
> values (%s, %s)", (5, "foo"))
> >>> cursor.execute("pysqlite_pragma expected_types =
> int, str")
> >>> cursor.execute("select id, name from test")
> >>> res = cursor.fetchone()
> >>> print res.id, res.name, res[0], res[1],
> res["id"], res["name"]
> 5 foo 5 foo 5 foo
> >>> print type(res.id), type(res.name)
> <type 'int'> <type 'string'>
> 
> >
>
http://members.nccw.net/kdahlhaus/pysqlite/index.html
> 
> Kevin, you're very welcome to contribute to our
> SQLite project at
> Sourceforge, if you like.
> 
> Gerhard
> -- 
> mail:   gerhard <at> bigfoot <dot> de      
> registered Linux user #64239
> web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP
> public key id AD24C930
> public key fingerprint: 3FCC 8700 3012 0A9E B0C9 
> 3667 814B 9CAA AD24 C930
> reduce(lambda x,y:x+y,map(lambda
x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))


=====
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kevin Dahlhausen                    kdahlhaus at yahoo.com

"Do or do not. There is no 'Try.'  Yoda

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com





More information about the Python-list mailing list