SQLAlchemy Backend Base Classes¶
BaseAlchemyBackend
¶
Bases: BaseSQLBackend
Backend class for backends that compile to SQLAlchemy expressions.
Attributes¶
current_database: str
property
¶
The name of the current database this client is connected to.
Functions¶
create_table(name, obj=None, *, schema=None, database=None, temp=False, overwrite=False)
¶
Create a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the new table. |
required |
obj |
pd.DataFrame | ir.Table | None
|
An Ibis table expression or pandas table that will be used to
extract the schema and the data of the new table. If not provided,
|
None
|
schema |
sch.Schema | None
|
The schema for the new table. Only one of |
None
|
database |
str | None
|
Name of the database where the table will be created, if not the default. |
None
|
temp |
bool
|
Should the table be temporary for the session. |
False
|
overwrite |
bool
|
Clobber existing data |
False
|
Returns:
Type | Description |
---|---|
Table
|
The table that was created. |
drop_table(name, *, database=None, force=False)
¶
insert(table_name, obj, database=None, overwrite=False)
¶
Insert data into a table.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_name |
str
|
The name of the table to which data needs will be inserted |
required |
obj |
pd.DataFrame | ir.Table | list | dict
|
The source data or expression to insert |
required |
database |
str | None
|
Name of the attached database that the table is located in. |
None
|
overwrite |
bool
|
If |
False
|
Raises:
Type | Description |
---|---|
NotImplementedError
|
If inserting data from a different database |
ValueError
|
If the type of |
list_databases(like=None)
¶
List databases in the current server.
load_data(table_name, data, database=None, if_exists='fail')
¶
Load data from a dataframe to the backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_name |
str
|
Name of the table in which to load data |
required |
data |
pd.DataFrame
|
Pandas DataFrame |
required |
database |
str | None
|
Database in which the table exists |
None
|
if_exists |
Literal['fail', 'replace', 'append']
|
What to do when data in |
'fail'
|
Raises:
Type | Description |
---|---|
NotImplementedError
|
Loading data to a table from a different database is not yet implemented |
raw_sql(query)
¶
Execute a query string.
The returned cursor object must be manually released.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
DDL or DML statement |
required |
schema(name)
¶
table(name, database=None, schema=None)
¶
Create a table expression from a table in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Table name |
required |
database |
str | None
|
The database the table resides in |
None
|
schema |
str | None
|
The schema inside
The |
None
|
Returns:
Type | Description |
---|---|
Table
|
Table expression |