37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
import sqlite3
|
|
import django
|
|
django.setup()
|
|
from tqdm import tqdm
|
|
|
|
from bloonsa_game.models import Level, Author
|
|
|
|
|
|
def run():
|
|
print("yes")
|
|
|
|
with sqlite3.connect("bloonsworld_levels.db") as db:
|
|
cursor = db.cursor()
|
|
cursor.execute("SELECT * FROM Levels")
|
|
|
|
for (levelNum, title, authorname, authorID, numPlays, numCompleted, rating, target, darts, data) in tqdm(cursor.fetchall()):
|
|
authorObj = Author.objects.filter(authorId=authorID).first()
|
|
if not authorObj:
|
|
authorObj = Author.objects.create(authorId=authorID,
|
|
name=authorname)
|
|
authorObj.save()
|
|
|
|
levelObj = Level.objects.filter(levelId=levelNum).first()
|
|
if not levelObj:
|
|
levelObj = Level.objects.create(author=authorObj,
|
|
levelId=levelNum,
|
|
title=title,
|
|
plays=numPlays,
|
|
beats=numCompleted,
|
|
rating=rating,
|
|
target=target,
|
|
darts=darts,
|
|
data=data)
|
|
|
|
levelObj.save()
|
|
|