|
Re: How big an integer in SQLite?: msg#00004python.db.pysqlite.user
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 David Pratt wrote: > I am used to using a bigint type in postgres in some cases for table > creation. I assume sqlite doesn't care how big the integer gets for an > id. Is this true? [...] SQLite's integer storage class is limited. It will use the platform's "long long" C type if it has it. This is a 64-bit signed type on your typical x86 box. I've run the attached example script on my Ubuntu x86 and it resulted in a maximum of 4611686018427387904 (2**62). After that, arithmetics get out of hand (integer overflow producing negative number, then always zeros). For larger numbers, you will have to use SQLite's float type. - -- Gerhard -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEVhDtdIO4ozGCH14RAgmlAKCUbuRL0XN36XYH+RBu4Ajt/APiLACgkeeS OBoFUB4rg5PS9OdXmv1tCeM= =YGJJ -----END PGP SIGNATURE----- from pysqlite2 import dbapi2 as sqlite con = sqlite.connect(":memory:") cur = con.cursor() cur.execute("create table test(x)") cur.execute("insert into test(x) values (2)") while True: cur.execute("update test set x=x*2") cur.execute("select x from test") result = cur.fetchone()[0] if result == 0: break print result, type(result) _______________________________________________ pysqlite mailing list pysqlite-IAPFreCvJWPBWskQ1e/+sw@xxxxxxxxxxxxxxxx http://lists.initd.org/mailman/listinfo/pysqlite |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Test if table is a table in sqlite db: 00004, David Pratt |
|---|---|
| Next by Date: | Re: How big an integer in SQLite?: 00004, David Pratt |
| Previous by Thread: | How big an integer in SQLite?i: 00004, David Pratt |
| Next by Thread: | Re: How big an integer in SQLite?: 00004, David Pratt |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |