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(self, host='localhost', user=None, password=None, port=3306, database=None, url=None, driver='pymysql')
¶
Create an Ibis client using the passed connection parameters.
Parameters¶
host Hostname user Username password Password port Port database Database to connect to url Complete SQLAlchemy connection string. If passed, the other connection arguments are ignored. driver Python MySQL database driver
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() # doctest: +ELLIPSIS [...] 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