So basically I have a function that retrieves data from an API and produces a data series with columns (Data, Realtime Start, Value) I then have a program that inserts table named using values from my dictionary. I, however, cannot figure out how to upload the data series to these tables. I tried many ways and it either inputs values from random data series elements or hit me with an error: AttributeError: 'Timestamp' object has no attribute 'translate'
here is the code:
country_index = input('Country Code: ')
engine = create_engine('mysql+pymysql://user:pass@localhost:3306/{}'.format(country_index))
connection = engine.connect()
for lines in countryDict[country_index]:
lines.splitlines()
fredder = fred.get_series_all_releases(lines)
def Database_Table_Creator():
for table in countryDict[country_index]:
table.splitlines()
queryCreateTable = """CREATE TABLE `{}`(
DATE int,
REALTIME_START int,
VALUE int
)""".format(table)
connection.execute(queryCreateTable)
fredder.to_sql(
name = '{}'.format(table),
con = connection,
index = False,
if_exists='append',
chunksize = 500)
connection.close()
Database_Table_Creator()