def fetch(engine, tablename, columns=None, selection=None, **kwargs):
import pandas as pd<EOL>if columns is None:<EOL><INDENT>columnstr = '<STR_LIT:*>'<EOL><DEDENT>else:<EOL><INDENT>columnstr = '<STR_LIT:U+002CU+0020>'.join('<STR_LIT>' % c for c in columns)<EOL><DEDENT>selectionstr = format_db_selection(selection, engine=engine)<EOL>qstr = '<STR_LIT>' % (columnstr, tablename, selectionstr)<EOL>tab = pd.read_sql(qstr, engine, **kwargs)<EOL>types = tab.apply(lambda x: pd.api.types.infer_dtype(x.values))<EOL>if not tab.empty:<EOL><INDENT>for col in types[types == '<STR_LIT>'].index:<EOL><INDENT>tab[col] = tab[col].astype(str)<EOL><DEDENT><DEDENT>return Table.from_pandas(tab).filled()<EOL>
Fetch data from an SQL table into an `EventTable`

    Parameters
    ----------
    engine : `sqlalchemy.engine.Engine`
        the database engine to use when connecting

    table : `str`,
        The name of table you are attempting to receive triggers
        from.

    selection
        other filters you would like to supply
        underlying reader method for the given format

    .. note::

       For now it will attempt to automatically connect you
       to a specific DB. In the future, this may be an input
       argument.

    Returns
    -------
    table : `GravitySpyTable`