How Do I Import a Csv File from Sqlite to Python
Con = Sqlite3. Connect(“Data. Db”)Cur = Con. Cursor()A_File = Open(“Test. Csv”)Rows = Csv. Reader(A_File)Cur. Executemany(“Insert into Data Values (? ,?)”...
con = sqlite3. connect(“data.db”)cur = con. cursor()a_file = open(“test.csv”)rows = csv. reader(a_file)cur. executemany(“INSERT INTO data VALUES (?, ?)”, rows)cur. execute(“SELECT * FROM data”)print(cur. fetchall())con. commit()
How do I import a CSV file into SQLite python?
- con = sqlite3. connect(“data.db”)
- cur = con. cursor()
- a_file = open(“test.csv”)
- rows = csv. reader(a_file)
- cur. executemany(“INSERT INTO data VALUES (?, ?)”, rows)
- cur. execute(“SELECT * FROM data”)
- print(cur. fetchall())
- con. commit()
How do I read a csv file in SQLite?
- Open the destination table to view then choose File -> Import CSV from the menu.
- Or you can right-click on the table name from the right panel (or even any data cell of the table), choose Import CSV .