Skip to content

Instantly share code, notes, and snippets.

@phracker
Forked from atsuya046/jsonToSqlite.py
Last active August 29, 2015 14:11
Show Gist options
  • Save phracker/56bc1219202e5d2f905c to your computer and use it in GitHub Desktop.
Save phracker/56bc1219202e5d2f905c to your computer and use it in GitHub Desktop.
# -*- coding:utf-8 -*-
import json
import sqlite3
JSON_FILE = "some.json"
DB_FILE = "some.db"
traffic = json.load(open(JSON_FILE))
conn = sqlite3.connect(DB_FILE)
foo = traffic[0]["foo"]
bar = traffic[0]["bar"]
data = [foo, bar]
c = conn.cursor()
c.execute('create table table_name (foo, bar)')
c.execute('insert into table_name values (?,?)', data)
conn.commit()
c.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment