Merge branch 'master' of https://github.apps.lci.ulsa.mx/Atenea/extraccion
This commit is contained in:
38
app.py
38
app.py
@@ -2,26 +2,6 @@ import psycopg2
|
||||
|
||||
from psycopg2 import pool
|
||||
|
||||
# Crear un pool de conexiones global
|
||||
connection_pool = psycopg2.pool.SimpleConnectionPool(
|
||||
minconn=1,
|
||||
maxconn=10, # Define el tamaño máximo del pool
|
||||
dbname=os.getenv("DBNAME"),
|
||||
user=os.getenv("DBUSER"),
|
||||
password=os.getenv("DBPASSWORD"),
|
||||
host=os.getenv("DBHOST"),
|
||||
port=os.getenv("DBPORT")
|
||||
)
|
||||
|
||||
def get_db_connection():
|
||||
"""Obtiene una conexión del pool"""
|
||||
return connection_pool.getconn()
|
||||
|
||||
def release_db_connection(conn):
|
||||
"""Libera una conexión y la devuelve al pool"""
|
||||
connection_pool.putconn(conn)
|
||||
|
||||
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.chrome.service import Service
|
||||
from selenium.webdriver.common.by import By
|
||||
@@ -38,6 +18,24 @@ from waitress import serve
|
||||
import pandas as pd
|
||||
from io import StringIO
|
||||
|
||||
# Crear un pool de conexiones global
|
||||
connection_pool = psycopg2.pool.ThreadedConnectionPool(
|
||||
minconn=1,
|
||||
maxconn=10, # Define el tamaño máximo del pool
|
||||
dbname=os.getenv("DBNAME"),
|
||||
user=os.getenv("DBUSER"),
|
||||
password=os.getenv("DBPASSWORD"),
|
||||
host=os.getenv("DBHOST"),
|
||||
port=os.getenv("DBPORT")
|
||||
)
|
||||
|
||||
def get_db_connection():
|
||||
"""Obtiene una conexión del pool"""
|
||||
return connection_pool.getconn()
|
||||
|
||||
def release_db_connection(conn):
|
||||
"""Libera una conexión y la devuelve al pool"""
|
||||
connection_pool.putconn(conn)
|
||||
|
||||
|
||||
# Set options for the Chromium browser
|
||||
|
||||
Reference in New Issue
Block a user