Re: [pysqlite] retrieving 64-bit numbers from SQLite
Bruce Greenblatt <bgreenblatt-/[email protected]> Fri, 12 Sep 2008 11:01:12 -0700 (PDT)
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
typeof(num) returns integer. Sorry, I did not originally realize that your code below was what you were suggesting I put into my Python script. When I convert it into Python, and put it in my script, I get an error on sqlite3_column_int64 as it is not defined. Is there something additional that I need to import in order to use this function? ----- Original Message ---- From: Roger Binns <[email protected]> To: About pysqlite and APSW. <list-pysqlite-FR6EJeJVuqdwc357pe9rcyQmJico6nz3epZhswDD4dQ@public.gmane.org> Sent: Friday, September 12, 2008 4:17:17 AM Subject: Re: [pysqlite] retrieving 64-bit numbers from SQLite -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Bruce Greenblatt wrote: > Yes. That's exactly how I know that the numbers appear to be correct in the database. Sorry for my poor wording. If I do a select of the table from the database, here's what I get: > > sqlite> select name, num from stats order by num_bytes desc limit 20; Try using ttypeof(num) to get the actual type SQLite is storing as. If it is integer then the code I pointed at is used: >> PY_LONG_LONG intval = sqlite3_column_int64(self->statement->st, i); >> if (intval < INT32_MIN || intval > INT32_MAX) { >> converted = PyLong_FromLongLong(intval); >> } else { >> converted = PyInt_FromLong((long)intval); >> } You can run the pysqlite test suite to verify its operation. The test suite would fail if the above code isn't working correctly. Roger -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFIyk+9mOOfHg372QQRAk/6AKCU+JzzH8xtE+275Sj7vI+BaLk8HQCdFjyQ wqx0E2hGJ72RBe54VTSwWvY= =QJjY -----END PGP SIGNATURE----- _______________________________________________ list-pysqlite mailing list list-pysqlite-FR6EJeJVuqdwc357pe9rcyQmJico6nz3epZhswDD4dQ@public.gmane.org http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite