Skip to main content

No project description provided

Project description

libSQL API for Python

PyPI

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.

Install

You can install the current release (MacOS and Linux):

$ pip install libsql-experimental

Getting Started

To try out your first libsql program, start the Python interpreter:

$ python

and 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')

Connecting to a database

import libsql_experimental as libsql

con = libsql.connect("hello.db")
cur = con.cursor()

Embedded replica

import libsql_experimental as libsql

con = libsql.connect("hello.db", sync_url="<url>", sync_auth="<auth token>")
con.sync()

Creating a table

cur.execute("CREATE TABLE users (id INTEGER, email TEXT);")

Inserting rows into a table

cur.execute("INSERT INTO users VALUES (1, 'alice@example.org')")

Querying rows from a table

print(cur.execute("SELECT * FROM users").fetchone())

Developing

Setup the development environment:

python3 -m venv .env
source .env/bin/activate
pip3 install maturin pyperf pytest

Build the development version and use it:

maturin develop && python3 example.py

Run the tests:

pytest

Run the libSQL benchmarks:

python3 perf-libsql.py

Run the SQLite benchmarks for comparison:

python3 perf-sqlite3.py

License

This project is licensed under the MIT license.

Contribution

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libsql_experimental-0.0.9.tar.gz (20.7 kB view hashes)

Uploaded Source

Built Distributions

libsql_experimental-0.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

libsql_experimental-0.0.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

libsql_experimental-0.0.9-cp311-cp311-macosx_11_0_arm64.whl (2.8 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

libsql_experimental-0.0.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

libsql_experimental-0.0.9-cp310-cp310-macosx_11_0_arm64.whl (2.8 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

libsql_experimental-0.0.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

libsql_experimental-0.0.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

libsql_experimental-0.0.9-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page