diff --git a/src/httpaste/backend/mysql/paste.py b/src/httpaste/backend/mysql/paste.py index 5e4057f..efa5f0e 100644 --- a/src/httpaste/backend/mysql/paste.py +++ b/src/httpaste/backend/mysql/paste.py @@ -1,5 +1,7 @@ from os import path from time import time +from importlib.resources import open_text + try: from mysql.connector.connection import MySQLConnection @@ -92,7 +94,7 @@ def init(connection: MySQLConnection): cursor = connection.cursor() - with open(path.join(path.dirname(__file__), 'paste.sql'), 'r') as fh: + with open_text('httpaste.backend.mysql', 'paste.sql') as fh: cursor.execute(fh.read()) diff --git a/src/httpaste/backend/mysql/user.py b/src/httpaste/backend/mysql/user.py index 7efebfc..a7148ff 100644 --- a/src/httpaste/backend/mysql/user.py +++ b/src/httpaste/backend/mysql/user.py @@ -1,4 +1,5 @@ from os import path +from importlib.resources import open_text try: from mysql.connector.connection import MySQLConnection except ImportError as e: @@ -83,7 +84,7 @@ def init(connection: MySQLConnection): cursor = connection.cursor() - with open(path.join(path.dirname(__file__), 'user.sql'), 'r') as fh: + with open_text('httpaste.backend.mysql', 'user.sql') as fh: cursor.execute(fh.read())