[Tutor] A toy example to have clarity on Sqlite3 module
Dennis Lee Bieber
wlfraed at ix.netcom.com
Tue Nov 16 15:22:37 EST 2021
On Tue, 16 Nov 2021 22:03:36 +0530, Manprit Singh
<manpritsinghece at gmail.com> declaimed the following:
>Just need to know, is this the correct implementation ? any suggestions
If it runs, then it is technically a correct implementation. Is it a
desirable implementation depends on one's environment.
I believe the ability to do operations directly with the Connection,
without using a Cursor, is an EXTENSION to the DB-API specification. Not
all database connectors may support this type of extension.
One of the goals of the DB-API specification is to abstract out
differences between actual database engines. In an ideal situation, one
would change the SQLite import to import some other connector module, and
only have to change the call to create the Connection. Things aren't quite
that "ideal", and different connectors use different styles of argument
passing -- which one can query the database (after connecting) to determine
how things are passed, and can programmatically modify the application SQL
syntax to work with that method.
So, for maximum compatibility, I'd stick with the "create
connection"/"create cursor" (a second reason may be that the extension
version may only be doing "autocommit"; using cursors usually allows for
disabling autocommit and manually grouping a sequence of SQL as a single
transaction, allowing one to rollback the entire group).
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
More information about the Tutor
mailing list