Esempio n. 1
0
 def select(self, query, bind=None):
     try:
         if bind:
             self.cursor.execute(query, bind)
         else:
             self.cursor.execute(query)
     except:
         log.exception()
         raise
Esempio n. 2
0
    def _dmlmany(self, statement, binds=None, autocommit=True):
        try:
            self.cursor.executemany(statement, binds)
            if autocommit:
                self.commit()

            return self.cursor.rowcount
        except:
            log.exception()
            if autocommit:
                self.rollback()
            raise
Esempio n. 3
0
    def select(self, statement, bind=None):
        """SELECT 문 실행을 위한 method

        :param statement: string. SQL 문장. (template 문자열, binding 변수 형식 모두 사용가능.)
        :param bind: tuple or list. binding 변수값.
        """
        try:
            if bind is None:
                self.cursor.execute(statement)
            else:
                self.cursor.execute(statement, bind)
        except:
            log.exception()
            raise
Esempio n. 4
0
    def __init__(self, user, passwd, dbname, host="localhost", port=3306, charset="utf8"):
        DBWrapper.__init__(self)

        try:
            log.debug(f"MySql connection info. ({host}:{user}/{passwd}@{dbname}")
            self.connector = MySQLdb.connect(host, user, passwd, dbname, port=port, charset=charset)
        except:
            log.exception()
            raise

        try:
            self.cursor = self.connector.cursor()
        except:
            log.exception()
            raise
Esempio n. 5
0
    def __init__(self, filename, auto_commit=None):
        DBWrapper.__init__(self)

        try:
            log.debug("Sqlite connection info. (%s)" % filename)
            # autoCommit : None | DEFERRED | IMMEDIATE | EXCLUSIVE
            self.connector = sqlite3.connect(filename, isolation_level=auto_commit)
            # self.connector = sqlite3.connect(filename)
        except:
            log.exception()
            raise

        try:
            self.cursor = self.connector.cursor()
        except:
            log.exception()
            raise