Re: SQLite3 and lastrowid

2010-11-19 Thread Alexander Gattin
Hello, On Fri, Nov 19, 2010 at 01:03:14PM +0100, Wolfgang Rohdewald wrote: > On Freitag 19 November 2010, Alexander Gattin wrote: > > It's better to select count(1) instead of > > count(*). not true, > > The latter may skip rows consisting > > entirely of NULLs IIRC. not true either. I've heard

Re: SQLite3 and lastrowid

2010-11-19 Thread Alain Ketterlin
Alexander Gattin writes: > On Fri, Nov 19, 2010 at 12:32:19PM +0100, Alain > Ketterlin wrote: >> Alexander Gattin writes: >> > It's better to select count(1) instead of >> > count(*). The latter may skip rows consisting >> > entirely of NULLs IIRC. >> >> Wrong: count(anyname) ignores NULL, wher

Re: SQLite3 and lastrowid

2010-11-19 Thread Alexander Gattin
Hello, On Fri, Nov 19, 2010 at 12:32:19PM +0100, Alain Ketterlin wrote: > Alexander Gattin writes: > > It's better to select count(1) instead of > > count(*). The latter may skip rows consisting > > entirely of NULLs IIRC. > > Wrong: count(anyname) ignores NULL, whereas count(*) does not. I'm u

Re: SQLite3 and lastrowid

2010-11-19 Thread Wolfgang Rohdewald
On Freitag 19 November 2010, Alexander Gattin wrote: > It's better to select count(1) instead of > count(*). The latter may skip rows consisting > entirely of NULLs IIRC. in some data bases count(1) is said to be faster than count(*), I believe -- Wolfgang -- http://mail.python.org/mailman/list

Re: SQLite3 and lastrowid

2010-11-19 Thread Alain Ketterlin
Alexander Gattin writes: >> The proper way to get the number of rows is to >> use the COUNT aggregate function, e.g., "SELECT >> COUNT(*) FROM TABLE1", which will return a >> single row with a single column containing the >> number of rows in table1. > > It's better to select count(1) instead of

Re: SQLite3 and lastrowid

2010-11-19 Thread Alexander Gattin
On Fri, Nov 19, 2010 at 01:14:34PM +0200, Alexander Gattin wrote: > On Tue, Nov 16, 2010 at 01:52:42PM -0800, Ian > wrote: > > The proper way to get the number of rows is to > > use the COUNT aggregate function, e.g., "SELECT > > COUNT(*) FROM TABLE1", which will return a > > single row with a sing

Re: SQLite3 and lastrowid

2010-11-19 Thread Alexander Gattin
Hello, On Tue, Nov 16, 2010 at 01:52:42PM -0800, Ian wrote: > The proper way to get the number of rows is to > use the COUNT aggregate function, e.g., "SELECT > COUNT(*) FROM TABLE1", which will return a > single row with a single column containing the > number of rows in table1. It's better to s

Re: SQLite3 and lastrowid

2010-11-16 Thread fuglyducky
On Nov 16, 1:52 pm, Ian wrote: > On Nov 16, 2:08 pm, fuglyducky wrote: > > > db_connect = sqlite3.connect('test.db') > > cursor = db_connect.cursor() > > > print(cursor.lastrowid) > > At this point you haven't executed a query yet, so there is no > meaningful value that cursor.lastrowid can take.

Re: SQLite3 and lastrowid

2010-11-16 Thread Ian
On Nov 16, 2:08 pm, fuglyducky wrote: > db_connect = sqlite3.connect('test.db') > cursor = db_connect.cursor() > > print(cursor.lastrowid) At this point you haven't executed a query yet, so there is no meaningful value that cursor.lastrowid can take. > # Choose random index from DB - need to und

Re: SQLite3 and lastrowid

2010-11-16 Thread Dan M
On Tue, 16 Nov 2010 13:08:15 -0800, fuglyducky wrote: > On Nov 16, 12:54 pm, Ian wrote: >> On Nov 16, 1:00 pm, fuglyducky wrote: >> >> > Before I added the second table I could simply run >> > 'print(cursor.lastrowid)' and it would give me the id number. >> > However, with two tables I am unable

Re: SQLite3 and lastrowid

2010-11-16 Thread fuglyducky
On Nov 16, 12:54 pm, Ian wrote: > On Nov 16, 1:00 pm, fuglyducky wrote: > > > Before I added the second table I could simply run > > 'print(cursor.lastrowid)' and it would give me the id number. However, > > with two tables I am unable to do this. > > It would help if you would show the code wher

Re: SQLite3 and lastrowid

2010-11-16 Thread Ian
On Nov 16, 1:00 pm, fuglyducky wrote: > Before I added the second table I could simply run > 'print(cursor.lastrowid)' and it would give me the id number. However, > with two tables I am unable to do this. It would help if you would show the code where you're trying to do this. Without your actu