Exemplo n.º 1
0
 def getCursor(self):
     try:
         #Conexion a postgre
         default        = DefaultConnection()
         self.conexion  = default.postgre_connect()
         cursor         = self.conexion.cursor(cursor_factory=psycopg2.extras.DictCursor)
         return cursor
     except Exception as e:
         logging.debug('Error obteniendo el cursor facade valoracion')
         raise Exception('Error no controlado: {}'.format(e.args[0]))			
     finally:            
         pass
Exemplo n.º 2
0
 def getCursor(self):
     try:
         #Conexion a postgre
         default = DefaultConnection()
         self.conexion = default.postgre_connect()
         cursor = self.conexion.cursor(
             cursor_factory=psycopg2.extras.DictCursor)
         return cursor
     except:
         print('Error obteniendo el cursor de dummy')
         raise Exception('Error no controlado: {}'.format(
             sys.exc_info()[0]))
     finally:
         pass
Exemplo n.º 3
0
 def __init__(self):
     """
     Cursor class
     """
     self.proxy = ProxyConfiguration()
     self.default_connection = DefaultConnection(self.proxy.engine)
Exemplo n.º 4
0
 def __init__(self, engine):
     """
     Constructor
     """
     self.default_connection = DefaultConnection(engine)
Exemplo n.º 5
0
class DML:
    """
    DataModelingLanguage class
    """
    default_connection = None
    logging.basicConfig(filename="test.log", level=logging.DEBUG)

    def __init__(self, engine):
        """
        Constructor
        """
        self.default_connection = DefaultConnection(engine)

    def create_dml(self):
        """
        Create datamodelinglanguage
        """
        logging.debug("DataModelingLanguage begin!")
        now = datetime.datetime(2009, 5, 5)
        now.strftime('%Y-%m-%d %H:%M:%S')
        _data = [1, [2, 3], {'a': [4, 5]}]
        _my_json = json.dumps(_data)
        logging.debug("dumps")
        beer_type = BeerType("IPA", Constant.user)
        pay_type = PayType("TARJETA_CREDITO", Constant.user)
        bar = Bar("Melas", now, "12", "24", "6", "a", "MELAS BAR",
                  "http://servidor/melas.jpg", "Calle 72 #11-07", "5",
                  "https://facebook/melas", "https://twitter/@melas",
                  "https://instragram/melas", "123", Constant.user)

        self.default_connection.get_beer_connection().session.add(beer_type)
        self.default_connection.get_beer_connection().session.add(pay_type)
        self.default_connection.get_beer_connection().session.add(bar)
        self.default_connection.get_beer_connection().session.flush()
        beer = Beer("Atomic IIPA", 16000, 10000, 75000, 38000, bar.id,
                    beer_type.id, "10%", "82", "40", "Doble IIPA",
                    "http://imagen/assets/images/dobleIIpa.jpg", "1", "1", "1",
                    "1", Constant.user)
        user = User("*****@*****.**", now,
                    "Kasdasda76sshd6a3naksjda_asda", "100000",
                    "http://servidor/foto.jpg", "0", Constant.user)
        self.default_connection.get_beer_connection().session.add(beer)
        self.default_connection.get_beer_connection().session.add(user)
        self.default_connection.get_beer_connection().session.flush()
        pairing = Pairing("Chorizo", "http://servidor/foto_pairing.jpg",
                          beer.id, Constant.user)
        promotion = Promotion(8, beer.id, Constant.user)
        taste = Taste("taste", beer.id, Constant.user)
        climate = Climate(_my_json, Constant.user)
        self.default_connection.get_beer_connection().session.add(pairing)
        self.default_connection.get_beer_connection().session.add(promotion)
        self.default_connection.get_beer_connection().session.add(taste)
        self.default_connection.get_beer_connection().session.add(climate)
        self.default_connection.get_beer_connection().session.commit()
        self.default_connection.get_beer_connection().session.close()
        logging.debug("DataModelingLanguage created!")

    def __str__(self):
        return self.__class__.__name__