From 879f20f1e72adf3d5c1496f4a9b49c72bd97b50c Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 5 Feb 2025 23:22:52 +1100 Subject: [PATCH] fix: Update db connector charset --- main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 8d7dcf1..eb358f0 100644 --- a/main.py +++ b/main.py @@ -51,6 +51,8 @@ db = mysql.connector.connect( user=DB_USER, password=DB_PASSWORD, database=DB_NAME, + charset='utf8mb4', + collation='utf8mb4_unicode_ci', ) def indexBlock(blockHeight): @@ -97,8 +99,8 @@ def saveBlock(blockData): def setupDB(): """Creates the database tables""" with db.cursor() as cursor: - cursor.execute("CREATE TABLE IF NOT EXISTS blocks (hash VARCHAR(64), height BIGINT, depth INT, version INT, prevBlock VARCHAR(64), merkleRoot VARCHAR(64), witnessRoot VARCHAR(64), treeRoot VARCHAR(64), reservedRoot VARCHAR(64), time INT, bits INT, nonce BIGINT UNSIGNED, extraNonce VARCHAR(64), mask VARCHAR(64), txs JSON) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci") - cursor.execute("CREATE TABLE IF NOT EXISTS transactions (hash VARCHAR(64), witnessHash VARCHAR(64), fee BIGINT, rate BIGINT, mtime BIGINT, block BIGINT, `index` INT, version INT, inputs JSON, outputs JSON, locktime BIGINT, hex LONGTEXT) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci") + cursor.execute("CREATE TABLE IF NOT EXISTS blocks (hash VARCHAR(64), height BIGINT, depth INT, version INT, prevBlock VARCHAR(64), merkleRoot VARCHAR(64), witnessRoot VARCHAR(64), treeRoot VARCHAR(64), reservedRoot VARCHAR(64), time INT, bits INT, nonce BIGINT UNSIGNED, extraNonce VARCHAR(64), mask VARCHAR(64), txs JSON)") + cursor.execute("CREATE TABLE IF NOT EXISTS transactions (hash VARCHAR(64), witnessHash VARCHAR(64), fee BIGINT, rate BIGINT, mtime BIGINT, block BIGINT, `index` INT, version INT, inputs JSON, outputs JSON, locktime BIGINT, hex LONGTEXT)") # Get the newest block height in the database def getNewestBlock() -> int: