I want to append the Pandas dataframe to an existing table in a sqlite database called \'NewTable\'. NewTable has three fields (ID, Name, Age) and ID is the primary key. My
http://pandas.pydata.org/pandas-docs/version/0.13.1/generated/pandas.io.sql.write_frame.html
curious if you tried replace
?
if_exists: {‘fail’, ‘replace’, ‘append’}, default ‘fail’
You can use SQL functionality insert or replace
query=''' insert or replace into NewTable (ID,Name,Age) values (?,?,?) '''
conn.executemany(query, test.to_records(index=False))
conn.commit()