classmethod DataFrame.from_db(table_name, name=None, roles=None, ignore=False, dry=False, conn=None)[source]

Create a DataFrame from a table in a database.

It will construct a data frame object in the engine, fill it with the data read from table table_name in the connected database (see database), and return a corresponding DataFrame handle.


table_name (str): Name of the table to be read.

name (str): Name of the data frame to be created. If not passed,

then the table_name will be used.

roles(dict[str, List[str]], optional): A dictionary mapping

the roles to the column names. If this is not passed, then the roles will be sniffed from the table. The roles dictionary should be in the following format:

>>> roles = {"role1": ["colname1", "colname2"], "role2": ["colname3"]}
ignore (bool, optional): Only relevant when roles is not None.

Determines what you want to do with any colnames not mentioned in roles. Do you want to ignore them (True) or read them in as unused columns (False)?

dry (bool, optional): If set to True, then the data

will not actually be read. Instead, the method will only return the roles it would have used. This can be used to hard-code roles when setting up a pipeline.

conn (Connection, optional):

The database connection to be used. If you don’t explicitly pass a connection, the engine will use the default connection.


TypeError: If any of the input arguments is of a wrong type.

ValueError: If one of the provided keys in roles does not match a definition in roles.



Handler of the underlying data.



loan ='loan', name='data_frame_loan')