MySQL
Install
Install Ibis and dependencies for the MySQL backend:
Install with the mysql
extra:
pip install 'ibis-framework[mysql]'
And connect:
import ibis
= ibis.mysql.connect() con
- 1
- Adjust connection parameters as needed.
Install for MySQL:
conda install -c conda-forge ibis-mysql
And connect:
import ibis
= ibis.mysql.connect() con
- 1
- Adjust connection parameters as needed.
Install for MySQL:
mamba install -c conda-forge ibis-mysql
And connect:
import ibis
= ibis.mysql.connect() con
- 1
- Adjust connection parameters as needed.
Connect
ibis.mysql.connect
= ibis.mysql.connect(
con ="username",
user="password",
password="hostname",
host=3306,
port="database",
database )
Note
ibis.mysql.connect
is a thin wrapper around ibis.backends.mysql.Backend.do_connect
.
Connection Parameters
do_connect
do_connect(self, host='localhost', user=None, password=None, port=1433, database=None, url=None, driver='pymssql')
ibis.connect
URL format
In addition to ibis.mysql.connect
, you can also connect to MySQL by passing a properly formatted MySQL connection URL to ibis.connect
= ibis.connect(f"mysql://{user}:{password}@{host}:{port}/{database}") con
mysql.Backend
create_database
create_database(self, name, force=False)
Create a new database.
Parameters
Name | Type | Description | Default |
---|---|---|---|
name |
str | Name of the new database. | required |
force |
bool | If False , an exception is raised if the database already exists. |
False |
drop_database
drop_database(self, name, force=False)
Drop a database with name name
.
Parameters
Name | Type | Description | Default |
---|---|---|---|
name |
str | Database to drop. | required |
force |
bool | If False , an exception is raised if the database does not exist. |
False |
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. |