當前位置: 首頁>>代碼示例>>Python>>正文


Python kinterbasdb.connect方法代碼示例

本文整理匯總了Python中kinterbasdb.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python kinterbasdb.connect方法的具體用法?Python kinterbasdb.connect怎麽用?Python kinterbasdb.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在kinterbasdb的用法示例。


在下文中一共展示了kinterbasdb.connect方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: checkConnect

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def checkConnect(self):
        """Check the connect/disconnect synchronous calls."""
        conn = self.dbpool.connect()
        self.checkOpenfunCalled(conn)
        curs = conn.cursor()
        curs.execute("insert into simple(x) values(1)")
        curs.execute("select x from simple")
        res = curs.fetchall()
        self.assertEqual(len(res), 1)
        self.assertEqual(len(res[0]), 1)
        self.assertEqual(res[0][0], 1)
        curs.execute("delete from simple")
        curs.execute("select x from simple")
        self.assertEqual(len(curs.fetchall()), 0)
        curs.close()
        self.dbpool.disconnect(conn) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:18,代碼來源:test_adbapi.py

示例2: checkConnect

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def checkConnect(self):
        """Check the connect/disconnect synchronous calls."""
        conn = self.dbpool.connect()
        self.checkOpenfunCalled(conn)
        curs = conn.cursor()
        curs.execute("insert into simple(x) values(1)")
        curs.execute("select x from simple")
        res = curs.fetchall()
        self.failUnlessEqual(len(res), 1)
        self.failUnlessEqual(len(res[0]), 1)
        self.failUnlessEqual(res[0][0], 1)
        curs.execute("delete from simple")
        curs.execute("select x from simple")
        self.failUnlessEqual(len(curs.fetchall()), 0)
        curs.close()
        self.dbpool.disconnect(conn) 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:18,代碼來源:test_adbapi.py

示例3: makeSQLTests

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def makeSQLTests(base, suffix, globals):
    """
    Make a test case for every db connector which can connect.

    @param base: Base class for test case. Additional base classes
                 will be a DBConnector subclass and unittest.TestCase
    @param suffix: A suffix used to create test case names. Prefixes
                   are defined in the DBConnector subclasses.
    """
    connectors = [GadflyConnector, SQLiteConnector, PyPgSQLConnector,
                  PsycopgConnector, MySQLConnector, FirebirdConnector]
    for connclass in connectors:
        name = connclass.TEST_PREFIX + suffix
        klass = new.classobj(name, (connclass, base, unittest.TestCase), base.__dict__)
        globals[name] = klass

# GadflyADBAPITestCase SQLiteADBAPITestCase PyPgSQLADBAPITestCase
# PsycopgADBAPITestCase MySQLADBAPITestCase FirebirdADBAPITestCase 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:20,代碼來源:test_adbapi.py

示例4: makeSQLTests

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def makeSQLTests(base, suffix, globals):
    """Make a test case for every db connector which can connect.

    @param base: Base class for test case. Additional base classes
                 will be a DBConnector subclass and unittest.TestCase
    @param suffix: A suffix used to create test case names. Prefixes
                   are defined in the DBConnector subclasses.
    """
    connectors = [GadflyConnector, SQLiteConnector, PyPgSQLConnector,
                  PsycopgConnector, MySQLConnector, FirebirdConnector]
    for connclass in connectors:
        name = connclass.TEST_PREFIX + suffix
        import new
        klass = new.classobj(name, (connclass, base, unittest.TestCase), {})
        globals[name] = klass

# GadflyADBAPITestCase SQLiteADBAPITestCase PyPgSQLADBAPITestCase
# PsycopgADBAPITestCase MySQLADBAPITestCase FirebirdADBAPITestCase 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:20,代碼來源:test_adbapi.py

示例5: can_connect

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def can_connect(self):
        try: from pyPgSQL import PgSQL
        except: return False
        try:
            conn = PgSQL.connect(database=self.DB_NAME, user=self.DB_USER,
                                 password=self.DB_PASS)
            conn.close()
            return True
        except:
            return False 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:12,代碼來源:test_adbapi.py

示例6: stopDB

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def stopDB(self):
        import kinterbasdb
        conn = kinterbasdb.connect(database=self.DB_NAME,
                                   host='127.0.0.1', user=self.DB_USER,
                                   password=self.DB_PASS)
        conn.drop_database() 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:8,代碼來源:test_adbapi.py

示例7: connect

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def connect(self):
        """
        Return an instance of C{self.connectionFactory}.
        """
        return self.connectionFactory() 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:7,代碼來源:test_adbapi.py

示例8: connect

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def connect(self):
        self.initConnection()

        if not self.hostname:
            self.checkFileDb()

        try:
            self.connector = kinterbasdb.connect(host=self.hostname.encode(UNICODE_ENCODING), database=self.db.encode(UNICODE_ENCODING), \
                user=self.user.encode(UNICODE_ENCODING), password=self.password.encode(UNICODE_ENCODING), charset="UTF8")  # Reference: http://www.daniweb.com/forums/thread248499.html
        except kinterbasdb.OperationalError, msg:
            raise SqlmapConnectionException(msg[1]) 
開發者ID:krintoxi,項目名稱:NoobSec-Toolkit,代碼行數:13,代碼來源:connector.py

示例9: connect

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def connect(self):
		
        import kinterbasdb
		
        try:
            kinterbasdb.init(type_conv=0)
        except:
            pass	
		
        self._db = kinterbasdb.connect(dsn=self._bdd,
                                       user=self._user,
                                       password=self._password,
                                       charset=self._charset)
        try:
            self._db.cursor().execute("DECLARE EXTERNAL FUNCTION lpad \
               CSTRING(255) NULL, INTEGER, CSTRING(1) NULL \
               RETURNS CSTRING(255) FREE_IT \
               ENTRY_POINT 'IB_UDF_lpad' MODULE_NAME 'ib_udf'")
        except:
            pass
        try:
            self._db.cursor().execute("DECLARE EXTERNAL FUNCTION Round \
                INT BY DESCRIPTOR, INT BY DESCRIPTOR \
                RETURNS PARAMETER 2 \
                ENTRY_POINT 'fbround' MODULE_NAME 'fbudf'")
        except:
            pass 
開發者ID:wfrog,項目名稱:wfrog,代碼行數:29,代碼來源:database.py

示例10: writeDB

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def writeDB(db, t):
    sql = """
INSERT INTO METEO (TIMESTAMP_UTC, TIMESTAMP_LOCAL, TEMP, TEMP_MIN, TEMP_MIN_TIME, TEMP_MAX,
               TEMP_MAX_TIME, HUM, WIND, WIND_DIR, WIND_GUST, WIND_GUST_DIR, WIND_GUST_TIME,
               DEW_POINT, RAIN, RAIN_RATE, RAIN_RATE_TIME, PRESSURE, UV_INDEX)
VALUES (%s, %s, %g, %g, %s, %g, %s, %g, %g, %s, %g, %s, %s, %g, %g, %g, %s, %g, %s)
""" % ("'%s'" % time.strftime(TIME_FORMAT, t),
   "'%s'" % time.strftime(TIME_FORMAT, t),
   random()*20-5,
   random()*10-10,
   "'%s'" % time.strftime(TIME_FORMAT, t),
   random()*30+10,
   "'%s'" % time.strftime(TIME_FORMAT, t),
   random()*100,
   random()*10,
   int(random()*360),
   random()*20,
   int(random()*360),
   "'%s'" % time.strftime(TIME_FORMAT, t),
   random()*20,
   random()*1000,
   random()*5,
   "'%s'" % time.strftime(TIME_FORMAT, t),
   random()*100+950,
   random()*5)
    try:
        bdd = db
        bdd.connect()
        bdd.execute(sql)
        bdd.disconnect()
        logging.debug("SQL executed: %s", sql)
    except:
        logging.exception("Error writting current data to database")
        return False
    return True 
開發者ID:wfrog,項目名稱:wfrog,代碼行數:37,代碼來源:datagenerator.py

示例11: connect

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def connect(self):
        self._db = kinterbasdb.connect(dsn=self._bdd,
                                       user=self._user,
                                       password=self._password,
                                       charset=self._charset) 
開發者ID:wfrog,項目名稱:wfrog,代碼行數:7,代碼來源:datagenerator.py

示例12: connect

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def connect(self):
        raise Exception("Method cannot be called") 
開發者ID:wfrog,項目名稱:wfrog,代碼行數:4,代碼來源:database.py

示例13: connect

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def connect(self, info):
        try:
            import kinterbasdb
        except:
            print "Missing Firebird support through kinterbasdb"
            return
        
        self.strDbms = 'firebird'
        self.version = info['version']
        self.conn = kinterbasdb.connect(
            dsn='localhost:%s' % info['dbname'],
            user = info['user'], 
            password = info['pass'])
        self.cursor = self.conn.cursor() 
開發者ID:gltn,項目名稱:stdm,代碼行數:16,代碼來源:FirebirdInterface.py

示例14: can_connect

# 需要導入模塊: import kinterbasdb [as 別名]
# 或者: from kinterbasdb import connect [as 別名]
def can_connect(self):
        try: import gadfly
        except: return False
        if not getattr(gadfly, 'connect', None):
            gadfly.connect = gadfly.gadfly
        return True 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:8,代碼來源:test_adbapi.py


注:本文中的kinterbasdb.connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。