Skip to content

Instantly share code, notes, and snippets.

@skatesham
Created August 23, 2022 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skatesham/879814fb56d8ace5864f453e0cb37d5a to your computer and use it in GitHub Desktop.
Save skatesham/879814fb56d8ace5864f453e0cb37d5a to your computer and use it in GitHub Desktop.
Get list json and send to table jsqlite
import json
import sqlite3
connection = sqlite3.connect('db.sqlite')
cursor = connection.cursor()
cursor.execute('Create Table if not exists Student (name Text, course Text, roll Integer)')
traffic = json.load(open('json_file.json'))
columns = ['name','course','roll']
for row in traffic:
keys= tuple(row[c] for c in columns)
cursor.execute('insert into Student values(?,?,?)',keys)
print(f'{row["name"]} data inserted Succefully')
connection.commit()
connection.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment