本文整理汇总了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)
示例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)
示例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
示例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
示例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
示例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()
示例7: connect
# 需要导入模块: import kinterbasdb [as 别名]
# 或者: from kinterbasdb import connect [as 别名]
def connect(self):
"""
Return an instance of C{self.connectionFactory}.
"""
return self.connectionFactory()
示例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])
示例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
示例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
示例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)
示例12: connect
# 需要导入模块: import kinterbasdb [as 别名]
# 或者: from kinterbasdb import connect [as 别名]
def connect(self):
raise Exception("Method cannot be called")
示例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()
示例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