def test_insert(): d = {"seasonEnd": [2015, 2014], "tournaments": [30, 33]} df = pd.DataFrame(d) with engine.connect() as conn: df.to_sql(name="season", con=conn.connection, if_exists="append", index=False)
write_to_gz(file_name, content) for i, match_url in enumerate(df_filtered['url']): dfms.append(scrape_matches(match_url)) print(i) dfms = [d for d in dfms if d is not None] df_matches = pd.concat(dfms) dfrs = [] for year in xrange(1990, 2015+1): url = "http://www.cuetracker.net/Rankings/%i-%i" % (year-1, year) dfrs.append(scrape_rankings(url, year)) df_rankings = pd.concat(dfrs) # write the dataframes to sqlite DB with engine.connect() as conn: # df_seasons.to_sql(name="season", con=conn.connection, if_exists="replace", index=False) # df_tournaments.to_sql(name="seasonevent", con=conn.connection, if_exists="replace", index=False) df_matches.to_sql(name="seasonmatch", con=conn.connection, if_exists="replace", index=False) df_rankings.to_sql(name="playerranking", con=conn.connection, if_exists="replace", index=False) # with engine.connect() as conn: # df = pd.read_sql(sql="select * from seasonmatch", con=conn.connection) # create session object # Session = sessionmaker(bind=engine) # session = Session() # # query_seasons() #