SQLite

https://www.sqlite.org

Install

Install Ibis and dependencies for the SQLite backend:

Install with the sqlite extra:

pip install 'ibis-framework[sqlite]'

And connect:

import ibis

con = ibis.sqlite.connect()
1
Adjust connection parameters as needed.

Install for SQLite:

conda install -c conda-forge ibis-sqlite

And connect:

import ibis

con = ibis.sqlite.connect()
1
Adjust connection parameters as needed.

Install for SQLite:

mamba install -c conda-forge ibis-sqlite

And connect:

import ibis

con = ibis.sqlite.connect()
1
Adjust connection parameters as needed.

Connect

ibis.sqlite.connect

Use an ephemeral, in-memory database.

con = ibis.sqlite.connect()

Connect to, or create, a local SQLite file

con = ibis.sqlite.connect("mydb.sqlite")
Note

ibis.sqlite.connect is a thin wrapper around ibis.backends.sqlite.Backend.do_connect.

Connection Parameters

do_connect

do_connect(self, database=None, type_map=None)

Create an Ibis client connected to a SQLite database.

Multiple database files can be accessed using the attach() method.

Parameters
Name Type Description Default
database str | Path | None File path to the SQLite database file. If None, creates an in-memory transient database and you can use attach() to add more files None
type_map dict[str, str | dt.DataType] | None 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. None
Examples
>>> import ibis
>>> ibis.sqlite.connect("path/to/my/sqlite.db")

ibis.connect URL format

In addition to ibis.sqlite.connect, you can also connect to SQLite by passing a properly formatted SQLite connection URL to ibis.connect:

con = ibis.connect("sqlite:///path/to/local/file")

The URL can be sqlite:// which will connect to an ephemeral in-memory database:

con = ibis.connect("sqlite://")

sqlite.Backend

attach

attach(self, name, path)

Connect another SQLite database file to the current connection.

Parameters

Name Type Description Default
name str Database name within SQLite required
path str | Path Path to sqlite3 database files required

Examples

>>> con1 = ibis.sqlite.connect("original.db")
>>> con2 = ibis.sqlite.connect("new.db")
>>> con1.attach("new", "new.db")
>>> con1.list_tables(database="new")

list_databases

list_databases(self, like=None)

List existing databases in the current connection.

Parameters

Name Type Description Default
like str | None A pattern in Python’s regex format to filter returned database names. None

Returns

Type Description
list[str] The database names that exist in the current connection, that match the like pattern if provided.
Back to top