本文整理匯總了Python中db.DB.cursor方法的典型用法代碼示例。如果您正苦於以下問題:Python DB.cursor方法的具體用法?Python DB.cursor怎麽用?Python DB.cursor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類db.DB
的用法示例。
在下文中一共展示了DB.cursor方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: register_tournament
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import cursor [as 別名]
def register_tournament(name):
"""
Adds tournament to tournament table
"""
tournament = (name, )
query = 'INSERT INTO "tournaments" ("name") VALUES (%s)'
db = DB()
db.cursor().execute(query, tournament)
db.conn.commit()
db.cursor().close()
示例2: register_player
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import cursor [as 別名]
def register_player(name):
"""
Adds a player to the tournament database.
Args:
name: the player's full name (need not be unique).
"""
player = (name, )
query = 'INSERT INTO "players" ("name") VALUES (%s)'
db = DB()
db.cursor().execute(query, player)
db.conn.commit()
db.cursor().close()
示例3: report_match
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import cursor [as 別名]
def report_match(tournament_id, winner, loser):
"""
Records the outcome of a single match between two players.
Args:
winner: the id number of the player who won
loser: the id number of the player who lost
"""
match = (winner, loser, )
query = 'INSERT INTO "matches" ("winner","loser") VALUES (%s,%s)'
db = DB()
db.cursor().execute(query, match)
db.conn.commit()
db.cursor().close()
示例4: DB
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import cursor [as 別名]
#!/usr/bin/env python
# Generate KML containing all POIs
from settings import *
import psycopg2
from db import DB
import simplekml
# Connect to database
d = DB()
cur = d.cursor()
# Styles
bbq_style = simplekml.Style()
bbq_style.labelstyle.color = 'ff0000ff' # Red
bbq_style.iconstyle.icon.href= 'http://planyourpicnic.dja.id.au/assets/img/barbecue.png'
furniture_table_style = simplekml.Style()
furniture_seat_style = simplekml.Style()
furniture_table_style.iconstyle.icon.href="http://planyourpicnic.dja.id.au/assets/img/picnic.png"
furniture_seat_style.iconstyle.icon.href="http://planyourpicnic.dja.id.au/assets/img/picnic.png" # for want of a better seat image
toilet_style = simplekml.Style()
toilet_style.labelstyle.color = 'ff0000ff' # Red
toilet_style.iconstyle.icon.href= 'http://planyourpicnic.dja.id.au/assets/img/toilets.png'