sqlite select max() on integer field returns quoted value

Graham Fawcett graham__fawcett at hotmail.com
Thu Jun 19 16:25:24 CEST 2003


Tertius <tertiusc at netscape.net> wrote in message news:<3EF0DA8E.5060800 at netscape.net>...
> I mean pysqlite.
> 
> Tertius wrote:
> > Hi,
> > 
> > I do a "select max(id) from table"
> > id is a integer primary key not null and fetchone() returns tuple with 
> > quoted value ('223',)
> > should it not rather be (223,) ?
> > 
> > Many thanks
> > Tertius
> >

Does this work?

cnx = connect('db')
c = cnx.cursor()
c.execute('-- types int')
c.execute('select max(id) from table')

Check out:
http://pysqlite.sourceforge.net/documentation/pysqlite/node10.html

"SQLite is typeless. It stores all data as text. However, all data
returned from PySQLite are cast into their respective Python types as
declared in the database schema, provided that said types are standard
ANSI SQL type (e.g. VARCHAR, INT, FLOAT, etc.)."

Based on this, my guess is that PySQLite is having trouble figuring
out what the type of a max() result ought to be, since max is not in
your schema (of course).

-- Graham




More information about the Python-list mailing list