fix(backend/mysql): load files through importlib
is required since package will be distributed as python egg
This commit is contained in:
parent
4a1cf1d007
commit
809ce6522b
2 changed files with 5 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
from os import path
|
from os import path
|
||||||
from time import time
|
from time import time
|
||||||
|
from importlib.resources import open_text
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from mysql.connector.connection import MySQLConnection
|
from mysql.connector.connection import MySQLConnection
|
||||||
|
|
@ -92,7 +94,7 @@ def init(connection: MySQLConnection):
|
||||||
|
|
||||||
cursor = connection.cursor()
|
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())
|
cursor.execute(fh.read())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
from os import path
|
from os import path
|
||||||
|
from importlib.resources import open_text
|
||||||
try:
|
try:
|
||||||
from mysql.connector.connection import MySQLConnection
|
from mysql.connector.connection import MySQLConnection
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
|
|
@ -83,7 +84,7 @@ def init(connection: MySQLConnection):
|
||||||
|
|
||||||
cursor = connection.cursor()
|
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())
|
cursor.execute(fh.read())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue