def write_DataFrame(dataframe,
                    tablename,
                    dbhandle=None,
                    index=False,
                    if_exists='replace'):

    dbhandle = connect(dbhandle)

    dataframe.to_sql(tablename,
                     con=dbhandle,
                     flavor='sqlite',
                     if_exists=if_exists)

    def indexStat(tablename, column):
        istat = ('create index %(tablename)s_%(column)s '
                 'on %(tablename)s(%(column)s)') % locals()
        return istat

    if index:

        cc = dbhandle.cursor()

        if type(index) is str:
            istat = indexStat(tablename, index)
            print istat
            db_execute(cc, istat)
        elif isinstance(index, (tuple, list)):
            for column in index:
                istat = indexStat(tablename, column)
                db_execute(cc, istat)

        cc.close()
write a pandas dataframe to an sqlite db, index on given columns
dataset/ETHPy150Open CGATOxford/cgat/CGAT/Database.py/write_DataFrame