示例#1
0
 def delete_one(coleccao, condicao):
     try:
         my_query = "delete from {} where {}".format(coleccao, condicao)
         Database.cursor.execute(my_query)
     except mysql.connector.ProgrammingError as err:
         if err.errno == errorcode.ER_SYNTAX_ERROR:
             errorDB.syntaxError(
                 "Erro de sintaxe, verfique a consulta SQL!!")
示例#2
0
 def update_all(atributo, colleccao):
     try:
         my_query = "update {} set {}".format(colleccao, atributo)
         Database.cursor.execute(my_query)
     except mysql.connector.ProgrammingError as err:
         if err.errno == errorcode.ER_SYNTAX_ERROR:
             errorDB.syntaxError(
                 "Erro de sintaxe, verfique a consulta SQL!!")
示例#3
0
 def find(atributo, coleccao):
     try:
         my_query = "select {} from {}".format(atributo, coleccao)
         Database.cursor.execute(my_query)
         return Database.cursor.fetchall()
     except mysql.connector.ProgrammingError as err:
         if err.errno == errorcode.ER_SYNTAX_ERROR:
             errorDB.syntaxError(
                 "Erro de sintaxe, verfique a consulta SQL!!")
     except mysql.connector.InterfaceError as e:
         raise mysql.connector.InterfaceError("{} Interface error".format(
             e.msg))
示例#4
0
    def find_by_query(query):
        try:
            Database.cursor.execute(query)
            return Database.cursor.fetchall()

        except mysql.connector.ProgrammingError as err:
            if err.errno == errorcode.ER_SYNTAX_ERROR:
                errorDB.syntaxError(
                    "Erro de sintaxe, verfique a consulta SQL!!")

        except mysql.connector.errors.DatabaseError as e:
            print("==========++++++@@@@@@@@@@@@@@@@@{}".format(e.msg))
            raise e

        except mysql.connector.InterfaceError as e:
            raise mysql.connector.InterfaceError("{} Interface error".format(
                e.msg))
示例#5
0
    def insert(coleccao, data):

        try:
            my_query = "insert into {} values ({})".format(coleccao, data)
            Database.cursor.execute(my_query)
        except mysql.connector.ProgrammingError as err:
            if err.errno == errorcode.ER_SYNTAX_ERROR:
                errorDB.syntaxError(
                    "Erro de sintaxe, verfique a consulta SQL!!")
            return None

        except AttributeError:
            print("Bugs Insert: {}".format(AttributeError.args))

        except errors.OperationalError as e:
            print("Many connection--{}".format(e.msg))

        except mysql.connector.InterfaceError as e:

            raise mysql.connector.InterfaceError("{} Interface error".format(
                e.msg))
示例#6
0
    def find_one_only(atributo, coleccao, condicao):
        try:
            my_query = "select {} from {} where {}".format(
                atributo, coleccao, condicao)
            Database.cursor.execute(my_query)
            return Database.cursor.fetchone()
        except mysql.connector.ProgrammingError as err:
            if err.errno == errorcode.ER_SYNTAX_ERROR:
                errorDB.syntaxError(
                    "Erro de sintaxe, verfique a consulta SQL!!")
                return None
        except mysql.connector.errors.DatabaseError as e:
            print("{}".format(e.msg))
            return None

        except AttributeError:
            print("Bugs:  {}".format(AttributeError))

            return None
        except mysql.connector.InterfaceError as e:
            raise mysql.connector.InterfaceError("{} Interface error".format(
                e.msg))