<commit_before>import urllib.request, json
import mysql.connector as mariadb

#address to grab JSON from
url="https://api.coinmarketcap.com/v1/ticker/"

#Load JSON data into memory
with urllib.request.urlopen(url) as jsonurl:
    data = json.loads(jsonurl.read().decode())

#Specify login details for database
#I need to get this separated out to a file
#    so passwords, etc. are not hard coded.
dbuser = "rex"
dbpassword = "<PASSWORD>"
dbhost = "rexoregan.linkpc.net"
dbdatabase = "cryptovalue"

#Connect to database specified above & create cursor for working with it.
mariadb_connection = mariadb.connect(user = dbuser, password = <PASSWORD>,
                                     host = dbhost, database = dbdatabase)
cursor = mariadb_connection.cursor()

#Specify the SQL statement to load data into the database
dbinsert = "INSERT INTO Table3 (curid,price_btc,last_updated) VALUES (%s,%s,%s)"


#Loop through all currencies from the JSON
count=0
while count < len(data):
    curid = data[count]["id"]
    price_btc = data[count]["price_btc"]
    last_updated = data[count]["last_updated"]
    
    print(curid)
    print(price_btc)
    print(last_updated)
    print()
    cursor.execute(dbinsert,(curid, price_btc, last_updated))
    mariadb_connection.commit()
    count = count + 1


<commit_msg>Removed debugging info and added finish note.<commit_after>import urllib.request, json
import mysql.connector as mariadb

#address to grab JSON from
url="https://api.coinmarketcap.com/v1/ticker/"

#Load JSON data into memory
with urllib.request.urlopen(url) as jsonurl:
    data = json.loads(jsonurl.read().decode())

#Specify login details for database
#I need to get this separated out to a file
#    so passwords, etc. are not hard coded.
dbuser = "rex"
dbpassword = "<PASSWORD>"
dbhost = "rexoregan.linkpc.net"
dbdatabase = "cryptovalue"

#Connect to database specified above & create cursor for working with it.
mariadb_connection = mariadb.connect(user = dbuser, password = <PASSWORD>,
                                     host = dbhost, database = dbdatabase)
cursor = mariadb_connection.cursor()

#Specify the SQL statement to load data into the database
dbinsert = "INSERT INTO Table3 (curid,price_btc,last_updated) VALUES (%s,%s,%s)"


#Loop through all currencies from the JSON
count=0
while count < len(data):
    curid = data[count]["id"]
    price_btc = data[count]["price_btc"]
    last_updated = data[count]["last_updated"]
    
    cursor.execute(dbinsert,(curid, price_btc, last_updated))
    count = count + 1

mariadb_connection.commit()
print("Finished inserting to database")


{'fraction_non_alphanumeric': 0.10560675883256529, 'fraction_numerical': 0.0030721966205837174, 'mean_word_length': 4.087890625, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '175435', 'n_tokens_mistral': 839, 'n_tokens_neox': 815, 'n_words': 248}