def write_to_database(p):
    gen = emit_flat_data(p)
    stream_to_database(gen)
示例#2
0
def write_to_database(p):
    gen = emit_flat_data(p)
    stream_to_database(gen)

def get_annual(con):
    return get_freq(con, "a")


def get_quarterly(con):
    return get_freq(con, "q")


def get_monthly(con):
    return get_freq(con, "m")


def read_dfs(db_file=DB_FILE):
    con = sqlite3.connect(db_file)
    dfa = get_annual(con)
    dfq = get_quarterly(con)
    dfm = get_monthly(con)
    con.close()
    return dfa, dfq, dfm


if __name__ == "__main__":
    import os
    from stream import emit_flat_data

    p = os.path.abspath("../data/1-07/1-07.txt")
    gen = emit_flat_data(p)
    write_to_database(gen)
示例#4
0
def get_freq(con, lit):
    if lit in "qma":  
        return pd.read_sql_query("SELECT * from data where freq = \'{}\' ".format(lit), con)
    else:
        raise ValueError

def get_annual(con):
    return get_freq(con, "a")

def get_quarterly(con):
    return get_freq(con, "q")

def get_monthly(con):
    return get_freq(con, "m")

def read_dfs (db_file = DB_FILE):
    con = sqlite3.connect(db_file)
    dfa = get_annual(con)
    dfq = get_quarterly(con)
    dfm = get_monthly(con)
    con.close()
    return dfa, dfq, dfm

if __name__ == "__main__":
    import os
    from stream import emit_flat_data
    p = os.path.abspath("../data/1-07/1-07.txt")
    gen = emit_flat_data(p)
    write_to_database(gen)