Skip to content

SQLite

Installation

pip install "toolfront[sqlite]"

Connection URL

Connect to SQLite by passing a connection URL to the Database constructor:

1
2
3
4
5
from toolfront import Database

db = Database(url="sqlite://")

revenue = db.ask("What's our total revenue this month?")
1
2
3
4
5
from toolfront import Database

db = Database(url="sqlite://{relative/path/to/mydb.sqlite}")

revenue = db.ask("What's our total revenue this month?")

Connection Parameters

Alternatively, connect using the Database.from_sqlite() method with parameters:

1
2
3
4
5
6
7
8
9
from toolfront import Database

# File-based database
db = Database.from_sqlite(database="/path/to/mydb.sqlite")

# In-memory database
db = Database.from_sqlite()

revenue = db.ask("What's our total revenue this month?")
PARAMETER DESCRIPTION
database

File path to the SQLite database file. If None, creates an in-memory transient database and you can use attach() to add more files.

TYPE: str DEFAULT: None

type_map

An optional mapping from a string name of a SQLite "type" to the corresponding Ibis DataType that it represents. This can be used to override schema inference for a given SQLite database.

TYPE: dict[str, str] DEFAULT: None

match_schema

Regex pattern to filter schemas. Mutually exclusive with match_tables.

TYPE: str DEFAULT: None

match_tables

Regex pattern to filter tables. Mutually exclusive with match_schema.

TYPE: str DEFAULT: None

**kwargs

Additional arguments passed to the DBAPI connection call.

TYPE: Any DEFAULT: {}