sqlite select max() on integer field returns quoted value 
Author Message
 sqlite select max() on integer field returns quoted value

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



Mon, 05 Dec 2005 05:25:31 GMT  
 sqlite select max() on integer field returns quoted value
I mean pysqlite.
Quote:

> 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



Mon, 05 Dec 2005 05:33:02 GMT  
 sqlite select max() on integer field returns quoted value

Quote:

> I mean pysqlite.


> > 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



Mon, 05 Dec 2005 22:25:24 GMT  
 sqlite select max() on integer field returns quoted value
Thanks Graham...It does work yes.
Also for the explanation of the "max() type". I just presumed that the
type of the column in question would be returned.
Guess i'll have to pay more attention to sqlite *types* :)

Tertius

Quote:

> 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



Tue, 06 Dec 2005 05:49:02 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. about returning min and max in an integer list

2. max integer value

3. Max value possible in COMP field ??

4. awk: putting quotes around a field value

5. tcl max string length unicode -- wxString --sqlite

6. PROP:Value not returning any record fields

7. Return selected application window on mousedown and return to Realbasic

8. tcl sql selecting and retrieving selected fields

9. CGI : getting selected values in a select-object

10. Selecting Fields Based On Field Name

11. RETURN / RETURN-FROM and values

12. Comparing value in an input field to any value from another file

 

 
Powered by phpBB® Forum Software