Created
February 8, 2016 15:21
-
-
Save benmcnelly/3a81bcd2e8f060edcfaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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