Re: [sqlite] Brief intro to SQLite in Python

2014-07-14 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 13/07/14 14:05, Simon Slavin wrote:
> But the examples of SQLite-via-Python code are clear and well written
> and may be useful for Python users who want to learn SQLite.

Sadly it neglects one huge surprising area.  The sqlite3 module shipped
with Python (aka pysqlite) tries to emulate some transactioning behaviour
from a random Python standard (DBAPI) to make it sort of look like other
databases, and overrides what SQLite naturally does.

It actually parses the SQL provided and auto-starts transactions that must
be manually committed or rolled back.  It also doesn't understand SQLite
fully and hence gets confused by things like WITH and SAVEPOINTs.

In other words the code you write is not the code that is executed, and if
you aren't careful you will get bitten.  For example the inserts go fast
because it added a BEGIN, but without a commit at judicious points
(including program exit) that data can be lost.

My APSW doc includes a page on the differences between pysqlite and APSW,
and also serves as a list of things that may be surprising about pysqlite.

  http://rogerbinns.github.io/apsw/pysqlite.html

> Especially for the triple-quoting needed for .execute().

That is a regular Python thing and unrelated to pysqlite or execute.
Single quoted strings end on the same line (you can backslash to continue
to next line like in C but it is ugly).  Triple quoted strings continue
across lines until the matching triple quote to close the string.

Roger
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iEYEARECAAYFAlPETsAACgkQmOOfHg372QSdhgCgpYdrerB7nrE2F+tqRushIScm
3o0AoLLC9djTNUb9Kx4V75GJpHeF9Hl3
=2TNc
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Brief intro to SQLite in Python

2014-07-14 Thread Kees Nuyt

On Sun, 13 Jul 2014 22:05:29 +0100, Simon Slavin 
wrote:

> A Python programmer was doing a lot of data processing in Python
> and wondered whether SQLite could speed it up:
> 
> 
> 
> The article and the database needs of the programmer are rather
> simple, and the results are unremarkable (fast DBMS is fast).
> But the examples of SQLite-via-Python code are clear and well
> written and may be useful for Python users who want to learn
> SQLite.  Especially for the triple-quoting needed for
> .execute().

His follow-up article is nice too:



-- 
Groet, Cordialement, Pozdrawiam, Regards,

Kees Nuyt

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Brief intro to SQLite in Python

2014-07-13 Thread Keith Medcalf

>A Python programmer was doing a lot of data processing in Python and
>wondered whether SQLite could speed it up:
>
>
>
>The article and the database needs of the programmer are rather simple,
>and the results are unremarkable (fast DBMS is fast).  But the examples
>of SQLite-via-Python code are clear and well written and may be useful
>for Python users who want to learn SQLite.  Especially for the triple-
>quoting needed for .execute().

Triple quoting is not required for .execute().  A Triple-Quote is a way of 
delimiting a string such that escape characters are not required to embed 
characters with semantic meaning within the string (ie, quote characters or 
line-ending characters). 




___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users