-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 14/06/13 10:31, Maxim Khitrov wrote:
> I'm writing SQLite bindings for Go [1].

I'm the author of SQLite bindings for Python - APSW.  One choice I made
was to mimic SQLite semantics into Python - essentially if it is a
function call/expensive operation in SQLite then that is also the case in
Python too.  I don't try to get anything in advance or for convenience, or
misrepresent SQLite semantics.

For example getting the result layout requires an explicit call:

  http://apidoc.apsw.googlecode.com/hg/cursor.html#apsw.Cursor.getdescription

What I do is expose "Connection" objects which correspond to a sqlite3*,
and "Cursor" objects which correspond to sqlite3_stmt*.  The whole
statement preparation thing is not exposed.  Behind the scenes there is a
cache of sqlite3_stmt* objects which are claimed and released as
necessary.  I believe that SQLite itself should provide the statement
caching because it has a notable performance benefit and is hard to get
exactly right.  Individual application developers will have even more trouble.

Query results are obtained via iteration on the Cursor as you can see in
the above doc link.  (I couldn't work out if Go supports an iteration
protocol in same way, especially getting the next member only as needed.)
 Here is example code for most of the functionality:

  http://apidoc.apsw.googlecode.com/hg/example.html

Another thing to look out for is that developers often want to trace the
SQL being executed, as well as how long it took, longest/popular queries
etc.  The dynamic nature of Python made it easy to create a supervisor
that can automatically do the tracing and reporting without code
modification, and with no cost when it isn't used:

  http://apidoc.apsw.googlecode.com/hg/execution.html#apsw-trace

There is a sqlite3_trace function but I don't use it because it expands
bindings which means you can't lookup the queries in your code.

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlG8B1EACgkQmOOfHg372QTgbACgwJgzpFhszsB/1orPJ2lIVksS
gqsAoNnkjOjFSmTz1C9/3egmLs+ztqSs
=x87s
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to