Skip to content

arcivanov/karellen-sqlite

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Karellen Sqlite Extensions

Gitter chat

About

This project contains Karellen Sqlite extensions to the standard Python SQLite3 module.

These extensions are verified to work with Python 3.x (x >= 3) on Linux x86_64 and have been verified to work with GA and Debug builds of CPython. Any CPython ABI-compliant Python should work as well (YMMV).

SQLite3 Update Hook

The SQLite3 update hook allows the hook to be notified if the database to which the connection is made was changed.

This a drop-in replacement that can be used as demonstrated in the example below. The name pysqlite2 was chosen to the driver to be discovered automatically by Django SQLite backend.

from pysqlite2 import connect

def hook(conn, op, db_name, table_name, rowid):
    """Handle notification here. Do not modify the connection!"""
    
with connect(":memory:") as conn:
    conn.set_update_hook(hook)
    conn.execute("CREATE TABLE a (int id);")
    conn.execute("INSERT INTO a VALUES (1);")

You can also use this library directly with your Python 3 without renaming:

from sqlite3 import connect
from karellen.sqlite3 import Connection

with connect(":memory:", factory=Connection):
    # Do something useful here
    pass

About

Karellen SQLite Extensions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%