Spaces:
Sleeping
Sleeping
kltn20133118
commited on
Update repository/ConfigDatabase.py
Browse files- repository/ConfigDatabase.py +49 -48
repository/ConfigDatabase.py
CHANGED
@@ -1,48 +1,49 @@
|
|
1 |
-
from sqlalchemy import create_engine, URL
|
2 |
-
from sqlalchemy.orm import DeclarativeBase
|
3 |
-
Base = DeclarativeBase()
|
4 |
-
from sqlalchemy.engine import create_engine, URL
|
5 |
-
from dotenv import load_dotenv
|
6 |
-
import os
|
7 |
-
load_dotenv()
|
8 |
-
MYSQL_USER_NAME=os.getenv('MYSQL_USER_NAME')
|
9 |
-
MYSQL_PASSWORD=os.getenv('MYSQL_PASSWOR')
|
10 |
-
MYSQL_PORT=os.getenv('MYSQL_PORT')
|
11 |
-
MYSQL_DATABASE=os.getenv('MYSQL_DATABASE')
|
12 |
-
MYSQL_HOST=os.getenv('MYSQL_HOST')
|
13 |
-
#IF USE DOCKER HOST = host.docker.internal
|
14 |
-
def get_db_engine():
|
15 |
-
dsn = URL.create(
|
16 |
-
drivername="mysql+pymysql",
|
17 |
-
username=MYSQL_USER_NAME,
|
18 |
-
password=MYSQL_PASSWORD,
|
19 |
-
host=MYSQL_HOST,
|
20 |
-
port=MYSQL_PORT,
|
21 |
-
database=MYSQL_DATABASE
|
22 |
-
)
|
23 |
-
connect_args = {
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
def get_db_engine1():
|
33 |
-
dsn = URL.create(
|
34 |
-
drivername="mysql+pymysql",
|
35 |
-
username=MYSQL_USER_NAME,
|
36 |
-
password=MYSQL_PASSWORD,
|
37 |
-
host=MYSQL_HOST,
|
38 |
-
port=MYSQL_PORT,
|
39 |
-
database=MYSQL_DATABASE
|
40 |
-
)
|
41 |
-
connect_args = {
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
1 |
+
from sqlalchemy import create_engine, URL
|
2 |
+
from sqlalchemy.orm import DeclarativeBase
|
3 |
+
Base = DeclarativeBase()
|
4 |
+
from sqlalchemy.engine import create_engine, URL
|
5 |
+
from dotenv import load_dotenv
|
6 |
+
import os
|
7 |
+
load_dotenv()
|
8 |
+
MYSQL_USER_NAME=os.getenv('MYSQL_USER_NAME')
|
9 |
+
MYSQL_PASSWORD=os.getenv('MYSQL_PASSWOR')
|
10 |
+
MYSQL_PORT=os.getenv('MYSQL_PORT')
|
11 |
+
MYSQL_DATABASE=os.getenv('MYSQL_DATABASE')
|
12 |
+
MYSQL_HOST=os.getenv('MYSQL_HOST')
|
13 |
+
#IF USE DOCKER HOST = host.docker.internal
|
14 |
+
def get_db_engine():
|
15 |
+
dsn = URL.create(
|
16 |
+
drivername="mysql+pymysql",
|
17 |
+
username=MYSQL_USER_NAME,
|
18 |
+
password=MYSQL_PASSWORD,
|
19 |
+
host=MYSQL_HOST,
|
20 |
+
port=MYSQL_PORT,
|
21 |
+
database=MYSQL_DATABASE
|
22 |
+
)
|
23 |
+
connect_args = {
|
24 |
+
"ssl_verify_cert": True,
|
25 |
+
"ssl_verify_identity": True,
|
26 |
+
"ssl_ca": 'cert.pem',
|
27 |
+
}
|
28 |
+
return create_engine(
|
29 |
+
dsn,
|
30 |
+
connect_args=connect_args,
|
31 |
+
)
|
32 |
+
def get_db_engine1():
|
33 |
+
dsn = URL.create(
|
34 |
+
drivername="mysql+pymysql",
|
35 |
+
username=MYSQL_USER_NAME,
|
36 |
+
password=MYSQL_PASSWORD,
|
37 |
+
host=MYSQL_HOST,
|
38 |
+
port=MYSQL_PORT,
|
39 |
+
database=MYSQL_DATABASE
|
40 |
+
)
|
41 |
+
connect_args = {
|
42 |
+
"ssl_verify_cert": True,
|
43 |
+
"ssl_verify_identity": True,
|
44 |
+
"ssl_ca": 'cert.pem',
|
45 |
+
}
|
46 |
+
return create_engine(
|
47 |
+
dsn,
|
48 |
+
connect_args=connect_args,
|
49 |
+
)
|