diff --git a/main.py b/main.py index 1daa956..b0f3576 100644 --- a/main.py +++ b/main.py @@ -141,12 +141,20 @@ def setupDB(): def getNewestBlock() -> int: """Returns the height of the newest block in the database""" - with dbGet.cursor() as cursor: + dbNB = mysql.connector.connect( + host=DB_HOST, + user=DB_USER, + password=DB_PASSWORD, + database=DB_NAME, + charset='utf8mb4', + collation='utf8mb4_unicode_ci', + ) + with dbNB.cursor() as cursor: cursor.execute("SELECT height FROM blocks ORDER BY height DESC LIMIT 1") newestBlock = cursor.fetchone() if newestBlock: return int(newestBlock[0]) - + dbNB.close() return -1