Custom pyDAL adapter for libsql (distributed SQLite)
Project description
libSQL for pyDAL
Basic driver/adapter for using libSQL/sqld (Turso) with pyDAL.
More info:
Examples:
Basic Usage with a SQLite compatible Database
from pydal import DAL
# import is required to set up libsql:// and sqld:// for pyDAL
import pydal_libsql
# Connecting to a libSQL/SQLite database
db = DAL("libsql://example.db")
# example pydal operations:
# Defining a 'person' table with some fields
db.define_table(
"person",
db.Field("name", "string"),
db.Field("age", "integer"),
db.Field("last_name", "string")
)
# Committing the changes to the database
db.commit()
# Inserting a record into the 'person' table
db.person.insert(name="Henk", age=33)
# Retrieving and printing the inserted record
print(db(db.person.name == "Henk").select().as_list())
Connecting to a SQLd Server
from pydal import DAL
# import is required to set up libsql:// and sqld:// for pyDAL:
import pydal_libsql
# Connect to a SQLd server running on localhost:8080
db = DAL("sqld://localhost:8080")
# ...
Using Turso's SQL Service
from dotenv import dotenv_values
from pydal import DAL
# import is required to set up libsql:// and sqld:// for pyDAL:
import pydal_libsql
# Load Turso credentials from .env file or replace with your values directly
env = dotenv_values()
uri = env.get("TURSO_DATABASE_URL") # Example: "libsql://your-database-name.turso.io"
token = env.get("TURSO_AUTH_TOKEN") # Example: "ey****"
# Set up the database connection with Turso's URI and authentication token
db = DAL(uri, driver_args={"auth_token": token})
# ...
Disclaimer
This project is an unofficial tool and is not affiliated, endorsed, or sponsored by the maintainers of pyDAL or Turso. All references to pyDAL and Turso are for compatibility and integration purposes only.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydal_libsql-0.2.0.tar.gz
(3.9 kB
view details)
Built Distribution
File details
Details for the file pydal_libsql-0.2.0.tar.gz
.
File metadata
- Download URL: pydal_libsql-0.2.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4db0d876bb14b51f6b016383a73744ce72a9343ba8aa7da893443ae56bee6ef |
|
MD5 | 95e3cb87e1f22d700b5bf991a8009764 |
|
BLAKE2b-256 | b7bd4a80228ed47cfb3a83ec57221c7bafd33b675e1c7c55f4122bf7b537a7e0 |
File details
Details for the file pydal_libsql-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: pydal_libsql-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.27.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f6cb7dc68ff187e082c89342c079d1bd74e9f24cd77afaec0cc472babd40477 |
|
MD5 | fbc2cf86f878b7af29058641851a3961 |
|
BLAKE2b-256 | 7be67f6d91b4bf1bc09f3f50522ccd286f13f27c7020fce69bbcdd0c81d2f607 |