本文整理匯總了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)