libSQL is an open source, open contribution fork of SQLite. We aim to evolve it to suit many more use cases than SQLite was originally designed for.
This source repository contains libSQL API bindings for Python, which aim to be compatible with the sqlite3 module.
You can install the current release (MacOS and Linux):
$ pip install libsql-experimental
To try out your first libsql program, start the Python interpreter:
$ pythonand then:
>>> import libsql_experimental as libsql
>>> con = libsql.connect("hello.db")
>>> cur = con.cursor()
>>> cur.execute("CREATE TABLE users (id INTEGER, email TEXT);")
<builtins.Result object at 0x102dcf8d0>
>>> cur.execute("INSERT INTO users VALUES (1, 'alice@example.org')")
<builtins.Result object at 0x102dcf4b0>
>>> cur.execute("SELECT * FROM users").fetchone()
(1, 'alice@example.org')import libsql_experimental as libsql
con = libsql.connect("hello.db")
cur = con.cursor()import libsql_experimental as libsql
url = os.getenv("LIBSQL_URL")
auth_token = os.getenv("LIBSQL_AUTH_TOKEN")
con = libsql.connect(database=url, auth_token=auth_token)
cur = con.cursor()import libsql_experimental as libsql
url = os.getenv("LIBSQL_URL")
auth_token = os.getenv("LIBSQL_AUTH_TOKEN")
con = libsql.connect("hello.db", sync_url=url, auth_token=auth_token)
con.sync()cur.execute("CREATE TABLE users (id INTEGER, email TEXT);")cur.execute("INSERT INTO users VALUES (1, 'alice@example.org')")print(cur.execute("SELECT * FROM users").fetchone())Setup the development environment:
python3 -m venv .env
source .env/bin/activate
pip3 install maturin pyperf pytestOr you can use NIX to drop you into a shell with everything installed
nix-shell
Build the development version and use it:
maturin develop && python3 example.py
Run the tests:
pytestRun the libSQL benchmarks:
python3 perf-libsql.pyRun the SQLite benchmarks for comparison:
python3 perf-sqlite3.pyThis project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in libSQL by you, shall be licensed as MIT, without any additional terms or conditions.