psql.py 889 Bytes
import psycopg2

class BaseDatos():
    def __init__(self):
        self.HOST = "192.168.10.59"
        self.PORT = 5432
        self.USER = "administrador"
        self.PASS = "administrador"
        self.DB = "isvareporte"
        self.SELECT = ""
    

    def __conectarr__(self):
        self.conn = psycopg2.connect(host=self.HOST, port=self.PORT, 
        database=self.DB, user=self.USER, password=self.PASS)
        self.cur = self.conn.cursor()
        self.resultado = ""

    def __desconectar__(self):
        self.conn.close()
        self.cur.close()

    def __leer__(self):
        self.cur.execute(self.SELECT)
        self.resultado = self.cur.fetchall()

    def __ValidarComando__(self):
        return(True)
    
    def Leer(self):
        if self.__ValidarComando__():
            self.__conectarr__()
            self.__leer__()
            self.__desconectar__()