本文整理汇总了Python中connection.Connection.commit方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.commit方法的具体用法?Python Connection.commit怎么用?Python Connection.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类connection.Connection
的用法示例。
在下文中一共展示了Connection.commit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import commit [as 别名]
def run (self):
"""Run the sql script in sql attribute. Will execute the script and
then commit any changes to database. Results of script will be put in
to table attribute. If testing is true, does nothing.
"""
if self.testing:
return
conn = Connection(self.db, self.host, self.user, self.passwd)
conn.execute(self.sql)
self.table = conn.fetch()
conn.commit()
示例2: Connection
# 需要导入模块: from connection import Connection [as 别名]
# 或者: from connection.Connection import commit [as 别名]
wconnection = Connection(host=os.environ["POSTGRES_HOST"],
dbname=os.environ["POSTGRES_DB"],
user=os.environ["POSTGRES_USER"],
password=os.environ["POSTGRES_PASS"])
wconnection.connect()
wcursor = wconnection.cursor()
# Create the tables if they don't exist yet.
wcursor.execute(CREATE_PRO_SCHEDULE)
wcursor.execute(CREATE_PRO_SCHEDULE_LOCATION)
wcursor.execute(CREATE_PRO_LATENESS)
wconnection.commit()
# Set the date for which we are processing the data.
DATE = datetime.date(2015, 9, 27)
TDZERO = datetime.timedelta(0, 0)
# Get all the schedules from the database.
rcursor.execute("SELECT rid, uid from schedule where start_date=%s and passenger_service=true and deleted=false and status not in ('B', '5')", (DATE,))
counter = 0
while True:
row = rcursor.fetchone()
if row is None:
break
counter += 1