本文整理汇总了Python中database.DBSession.execute方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.execute方法的具体用法?Python DBSession.execute怎么用?Python DBSession.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.DBSession
的用法示例。
在下文中一共展示了DBSession.execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import execute [as 别名]
def start(self):
db_session = DBSession()
for sql in sql_statements:
try:
db_session.execute(sql)
except:
pass
示例2: apply_dialect_specific_codes
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import execute [as 别名]
def apply_dialect_specific_codes():
"""
Apply database engine specific codes. Unlike schema migration codes, these codes are applied to
new CSM installation which does not require schema migration.
"""
db_session = DBSession()
# For MYSQL: MEDIUMTEXT stores 2^24 characters. TEXT (65535) type is not enough when working with NCS6K
# Multi-Chassis which has twice as much information as a single chassis.
try:
db_session.execute('alter table host_context modify data MEDIUMTEXT')
db_session.execute('alter table conformance_report modify hostnames MEDIUMTEXT')
except Exception:
pass
示例3: start
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import execute [as 别名]
def start(self):
db_session = DBSession()
for sql in sql_statements:
try:
db_session.execute(sql)
except Exception as e:
pass
try:
# Re-discover all software inventory for all hosts due to changes in Condoor
inventory_jobs = db_session.query(InventoryJob)
for inventory_job in inventory_jobs:
inventory_job.request_update = True
db_session.commit()
except Exception as e:
pass
示例4: start
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import execute [as 别名]
def start(self):
db_session = DBSession()
for sql in sql_statements:
try:
db_session.execute(sql)
except:
pass
try:
# Creates a context for existing hosts
hosts = db_session.query(Host).all()
for host in hosts:
host.context.append(HostContext())
if len(host.connection_param) > 0:
connection = host.connection_param[0]
if connection.port_number is None:
connection.port_number = ''
db_session.commit()
except:
pass
示例5: start
# 需要导入模块: from database import DBSession [as 别名]
# 或者: from database.DBSession import execute [as 别名]
def start(self):
try:
db_session = DBSession()
db_session.execute('alter table system_option add base_url VARCHAR(100)')
except:
pass