本文整理汇总了Python中dbapi20.DatabaseAPI20Test方法的典型用法代码示例。如果您正苦于以下问题:Python dbapi20.DatabaseAPI20Test方法的具体用法?Python dbapi20.DatabaseAPI20Test怎么用?Python dbapi20.DatabaseAPI20Test使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbapi20
的用法示例。
在下文中一共展示了dbapi20.DatabaseAPI20Test方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: import dbapi20 [as 别名]
# 或者: from dbapi20 import DatabaseAPI20Test [as 别名]
def setUp(self):
# Call superclass setUp In case this does something in the
# future
dbapi20.DatabaseAPI20Test.setUp(self)
con = self._connect()
con.close()
if self.testMethodName()=='test_callproc':
sql="""
create procedure templower
@theData varchar(50)
as
select lower(@theData)
"""
con = self._connect()
cur = con.cursor()
try:
cur.execute(sql)
con.commit()
except:
pass
self.lower_func='templower'
示例2: __init__
# 需要导入模块: import dbapi20 [as 别名]
# 或者: from dbapi20 import DatabaseAPI20Test [as 别名]
def __init__(self,arg):
dbapi20.DatabaseAPI20Test.__init__(self,arg)
示例3: tearDown
# 需要导入模块: import dbapi20 [as 别名]
# 或者: from dbapi20 import DatabaseAPI20Test [as 别名]
def tearDown(self):
if self.testMethodName()=='test_callproc':
con = self._connect()
cur = con.cursor()
cur.execute("drop procedure templower")
con.commit()
dbapi20.DatabaseAPI20Test.tearDown(self)
示例4: setUp
# 需要导入模块: import dbapi20 [as 别名]
# 或者: from dbapi20 import DatabaseAPI20Test [as 别名]
def setUp(self):
# Call superclass setUp in case this does something in the future
dbapi20.DatabaseAPI20Test.setUp(self)
try:
con = self._connect()
con.close()
except pgdb.Error: # try to create a missing database
import pg
try: # first try to log in as superuser
db = pg.DB('postgres', dbhost or None, dbport or -1,
user='postgres')
except Exception: # then try to log in as current user
db = pg.DB('postgres', dbhost or None, dbport or -1)
db.query('create database ' + dbname)
示例5: tearDown
# 需要导入模块: import dbapi20 [as 别名]
# 或者: from dbapi20 import DatabaseAPI20Test [as 别名]
def tearDown(self):
dbapi20.DatabaseAPI20Test.tearDown(self)