forked from serhii-korobchenko/Python_Web_Team2_project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
34 lines (27 loc) · 849 Bytes
/
db.py
File metadata and controls
34 lines (27 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.engine import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
import psycopg2
import os
from env import main
# #PostgreSQL database credentials
# main()
# user = os.environ.get('LOGIN')
# password = os.environ.get('PASSWORD')
#
# print(f'________________________________{os.environ.get("LOGIN")}')
#
# host = 'rogue.db.elephantsql.com'
# port = '5432'
# database = 'vtskvycg'
#
# # create an engine to connect to the database
# engine = create_engine(f'postgresql://{user}:{password}@{host}:{port}/{database}')
# SQLite
engine = create_engine(
"sqlite:///cli_bot.db", connect_args={"check_same_thread": False}, echo=True
)
db_session = scoped_session(
sessionmaker(autocommit=False, autoflush=False, bind=engine)
)
Base = declarative_base()