[Python logging] importing Pandas Dataframe into Sqlite3 and dataframesqlite3
Use pandas. io connector to input Sqlite
Import sqlite3 as litefrom pandas. io import sqlimport pandas as pd
According to if_exists, input sqlite in three modes:
The following parameters are available: failed, replace, and append.
# Link sqlite Data Sheet cnx = lite. connect ('data. db ') # selecting the region name to be imported into dataframe # The region name should be the same as the region name of the resource to be imported into SQL _df = df.. loc [:, ['column Name a', 'column Name ', 'column Name a'] # import SQL _df data into Table Name Daily_Record # if_exists configure failed to create A new Daily_Record table and import SQL _df data SQL. write_frame (SQL _df, name = 'daily _ Record ', con = cnx) # if_exists select "replace" as the "Daily_Record" table that already exists. # Delete the "Daily_Record" table and re-create the SQL statement that records the "SQL _df" table. write_frame (SQL _df, name = 'daily _ Record ', con = cnx, if_exists = 'replace ') # if_exists: Select appappnd as Daily_Record. The table already has data. Insert the SQL _df data into the SQL statement. write_frame (SQL _df, name = 'daily _ Record ', con = cnx, if_exists = 'append ')