Skip to content

SQLite

filebadge

ibis.memtable Support memtable

The SQLite backend supports memtables by constructing a string with the contents of the in-memory object. This will be very inefficient for medium to large in-memory tables. Please file an issue if you observe performance issues when using in-memory tables.

Install

Install ibis and dependencies for the SQLite backend:

pip install 'ibis-framework[sqlite]'
conda install -c conda-forge ibis-sqlite
mamba install -c conda-forge ibis-sqlite

Connect

ibis.sqlite.connect

con = ibis.sqlite.connect()  # (1)
  1. Use an ephemeral, in-memory database
con = ibis.sqlite.connect("mydb.sqlite")  # (1)
  1. Connect to, or create, a local SQLite file

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

Connection Parameters

do_connect(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")
con = ibis.connect("sqlite://") # (1)
  1. ephemeral, in-memory database

Last update: August 1, 2023