Store QTPyLib-compatible csv files in Blotter's MySQL.
    TWS/GW data are required for determining futures/options expiration

    :Parameters:
        df : dict
            Tick/Bar data

    :Optional:
        blotter : str
            Store MySQL server used by this Blotter (default is "auto detect")
        kind : str
            Is this ``BAR`` or ``TICK`` data

def store_data(df, blotter=None, kind="BAR"):
    """
    Store QTPyLib-compatible csv files in Blotter's MySQL.
    TWS/GW data are required for determining futures/options expiration

    :Parameters:
        df : dict
            Tick/Bar data

    :Optional:
        blotter : str
            Store MySQL server used by this Blotter (default is "auto detect")
        kind : str
            Is this ``BAR`` or ``TICK`` data
    """

    # validate columns
    valid_cols = validate_columns(df, kind)
    if not valid_cols:
        raise ValueError('Invalid Column list')

    # load blotter settings
    blotter_args = load_blotter_args(
        blotter, logger=logging.getLogger(__name__))

    # blotter not running
    if blotter_args is None:
        raise Exception("Cannot connect to running Blotter.")

    # cannot continue
    if blotter_args['dbskip']:
        raise Exception("Cannot continue. Blotter running with --dbskip")

    # connect to mysql using blotter's settings
    dbconn = pymysql.connect(
        client_flag=MULTI_STATEMENTS,
        host=str(blotter_args['dbhost']),
        port=int(blotter_args['dbport']),
        user=str(blotter_args['dbuser']),
        passwd=str(blotter_args['dbpass']),
        db=str(blotter_args['dbname']),
        autocommit=True
    )
    dbcurr = dbconn.cursor()

    # loop through symbols and save in db
    for symbol in list(df['symbol'].unique()):
        data = df[df['symbol'] == symbol]
        symbol_id = get_symbol_id(symbol, dbconn, dbcurr)

        # prepare columns for insert
        data.loc[:, 'timestamp'] = data.index.strftime('%Y-%m-%d %H:%M:%S')
        data.loc[:, 'symbol_id'] = symbol_id

        # insert row by row to handle greeks
        data = data.to_dict(orient="records")

        if kind == "BAR":
            for _, row in enumerate(data):
                mysql_insert_bar(row, symbol_id, dbcurr)
        else:
            for _, row in enumerate(data):
                mysql_insert_tick(row, symbol_id, dbcurr)

        try:
            dbconn.commit()
        except Exception as e:
            return False

    return True