Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Json database
- import pymysql
- import json
- def json_butikker():
- open_json = open('Rossmann.json','r').read()
- Rossmann = json.loads(open_json)
- cnx = pymysql.connect(user='root',
- password='1234',
- host='127.0.0.1',
- database='jsondb')
- cursor = cnx.cursor()
- for item in Rossmann:
- name = item['name']
- zipcode = item['stadt'].split(' ')[0]
- city =item['stadt'].split(' ')[1]
- adress = item['strasse']
- cursor.execute('INSERT INTO TyskKonkurenter (Navne_Butik, Postnr, By_Navn, Adresse) VALUES (%s, %s, %s, %s)',
- (name, zipcode, city, adress))
- cnx.commit()
- cnx.close()
- json_butikker()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement