-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.py
More file actions
27 lines (21 loc) · 734 Bytes
/
scripts.py
File metadata and controls
27 lines (21 loc) · 734 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
from sqlalchemy import create_engine
from sqlalchemy import text
from configs import *
import logging
import sys
logging.basicConfig(
filename='logs.log',
level=logging.INFO,
format='%(asctime)s,%(filename)s,%(levelname)s,%(message)s')
if __name__=='__main__':
try:
engine = create_engine(CONN_DB, echo=False)
logging.info("Coneccion con Base de Datos exitosa")
for ruta in RUTAS:
sentencia_sql = open(ruta,"r")
consulta = text(sentencia_sql.read())
engine.execute(consulta)
logging.info("Se crearon las tablas en la Base de Datos")
except:
logging.critical("No se pudo conectar a la base de datos")
sys.exit()