Skip to content

Instantly share code, notes, and snippets.

@benmcnelly
Created February 8, 2016 15:21
Show Gist options
  • Save benmcnelly/3a81bcd2e8f060edcfaf to your computer and use it in GitHub Desktop.
Save benmcnelly/3a81bcd2e8f060edcfaf to your computer and use it in GitHub Desktop.
import json
import sqlite3
traffic = json.load(open('https://api.onthecity.org/ministries/2773260'))
db = mysql.connect("cccdatabase.mysql")
query = "insert into ministries values (?,?,?,?,?,?,?)"
columns = ['name', 'about', 'group', 'subgroup', 'image', 'link']
for timestamp, data in traffic.iteritems():
keys = (timestamp,) + tuple(data[c] for c in columns)
c = db.cursor()
c.execute(query, keys)
c.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment