While cursors are generic to all databases, to me the test and code sample
seems to be very specific to Python.  Looking at the code I can't imagine
there are actually any SQLite C calls within the cursor() method.
sqlite3.Connection() undoubtedly maps to sqlite3_open() and cursor.execute()
would map to sqlite3_exec (or more likely the lower-level functions).  But
there's nothing in SQLite that I can see which would map to cursor() (i.e.,
nothing between opening the connection and preparing a statement).

For example in .NET an analogous routine would be:

using(DbConnection cnn = factory.CreateConnection()) {
  cnn.ConnectionString = "...";
  cnn.Open();
  using(DBCommand cmd = cnn.CreateCommand()) {
    cmd.CommandTest = "SELECT * FROM TABLE";
    using(DbDataReader reader = cmd.ExecuteReader()) {
      ... read rows here ...
    }
  }
}

So the cursor() method in Python is somewhat like the CreateCommand() method
in .NET and in .NET CreateCommand is just an internal object allocation, it
has nothing to do with SQLite.  However, in .NET we would also want to reuse
commands just like we use connections 'cause a command represents a parsed
statement.

Best regards,

Sam



-------------------------------------------
We're Hiring! Seeking a passionate developer to join our team building
products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
 
-----Original Message-----
From: Martin Jenkins [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 01, 2007 10:50 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] How fast is the sqlite connection created?

A cursor is the thing that you use to run your queries. Eg in Python's 
wrappers you import the wrapper (library, module) Connections to the 
database and create cursors on those Connections to do the actual work.

import sqlite3
conn=sqlite3.Connection(dbname)
crsr=conn.cursor()
crsr.execute("select * trom table")
result_set=crsr.fetchone()
...
result_set=crsr.fetchall()

and so on. SQLite cursors can only move forward in the result set. AIUI 
cursors in some older/bigger databases can move in either direction.

FWIW it looks like calling cursor() takes ~1.9us on my machine with 
Python2.5, sqlite3, disk file with schema of "create table t(a,b,c)".

Martin

----------------------------------------------------------------------------
-
To unsubscribe, send email to [EMAIL PROTECTED]
----------------------------------------------------------------------------
-


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to