Skip to content

MySQL

Install

Install ibis and dependencies for the MySQL backend:

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

Connect

API

Create a client by passing in a SQLAlchemy-style URI to ibis.mysql.connect.

See ibis.backends.mysql.Backend.do_connect for connection parameter information.

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

Connection Parameters

do_connect(host='localhost', user=None, password=None, port=3306, database=None, url=None, driver='pymysql')

Create an Ibis client using the passed connection parameters.

Parameters:

Name Type Description Default
host str

Hostname

'localhost'
user str | None

Username

None
password str | None

Password

None
port int

Port

3306
database str | None

Database to connect to

None
url str | None

Complete SQLAlchemy connection string. If passed, the other connection arguments are ignored.

None
driver Literal['pymysql']

Python MySQL database driver

'pymysql'

Examples:

>>> import os
>>> import getpass
>>> host = os.environ.get('IBIS_TEST_MYSQL_HOST', 'localhost')
>>> user = os.environ.get('IBIS_TEST_MYSQL_USER', getpass.getuser())
>>> password = os.environ.get('IBIS_TEST_MYSQL_PASSWORD')
>>> database = os.environ.get('IBIS_TEST_MYSQL_DATABASE',
...                           'ibis_testing')
>>> con = connect(
...     database=database,
...     host=host,
...     user=user,
...     password=password
... )
>>> con.list_tables()
[...]
>>> t = con.table('functional_alltypes')
>>> t
MySQLTable[table]
  name: functional_alltypes
  schema:
    index : int64
    Unnamed: 0 : int64
    id : int32
    bool_col : int8
    tinyint_col : int8
    smallint_col : int16
    int_col : int32
    bigint_col : int64
    float_col : float32
    double_col : float64
    date_string_col : string
    string_col : string
    timestamp_col : timestamp
    year : int32
    month : int32

Backend API

Backend


Last update: March 1, 2022