當前位置: 首頁>>代碼示例>>Python>>正文


Python DB.cursor方法代碼示例

本文整理匯總了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()
開發者ID:obelesk411,項目名稱:udacity_tournament_project,代碼行數:13,代碼來源:tournament.py

示例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()
開發者ID:obelesk411,項目名稱:udacity_tournament_project,代碼行數:16,代碼來源:tournament.py

示例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()
開發者ID:obelesk411,項目名稱:udacity_tournament_project,代碼行數:16,代碼來源:tournament.py

示例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'
開發者ID:daxtens,項目名稱:planyourpicnic,代碼行數:33,代碼來源:gen_kml_all.py


注:本文中的db.DB.cursor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。