本文整理匯總了Python中db.DB.update方法的典型用法代碼示例。如果您正苦於以下問題:Python DB.update方法的具體用法?Python DB.update怎麽用?Python DB.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類db.DB
的用法示例。
在下文中一共展示了DB.update方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: AddEvent
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import update [as 別名]
class AddEvent(tornado.web.RequestHandler):
def initialize(self):
self.webdatabase = DB()
def get(self):
token = self.get_argument('token', None)
platform = self.get_argument('platform', None)
low = self.get_argument('low', None)
high = self.get_argument('high', None)
language = self.get_argument('language', '')
if self.webdatabase.exists(token, platform):
d = dict()
if low:
d['low'] = float(low)
if high:
d['high'] = float(high)
if language:
d['language'] = language
try:
self.webdatabase.update(token, platform, d)
self.write('success')
except Exception as e:
self.write(str(e))
else:
if not low:
low = -1.0
if not high:
high = -1.0
try:
self.webdatabase.insert(token, platform, low, high, language)
self.write('success')
except Exception as e:
self.write(str(e))
示例2: __init__
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import update [as 別名]
class Notes:
#Database names
database = "NOTES"
note_id = "id"
data = "data"
name= "name"
password = "password"
#Actual Note ID
noteID = None
def __init__(self,noteID):
self.DB = DB(self.database, self.note_id)
self.noteID = noteID
def noteID(self):
return noteID
def index(self):
return self.DB.select_all([self.note_id ,self.name],None,None,None)
def select_note(self):
row = self.DB.select_one(self.noteID, [self.data])
if row:
return str(row[0])
return None
def update_note(self, text):
return self.DB.update(self.noteID,[self.data],[text])
def update_note_name(self,name):
return self.DB.update(self.noteID,[self.name],[name])
def add_note(self,text,name):
return self.DB.insert([self.data,self.name,self.password],[text,name,None])
def remove_note(self):
return self.DB.remove(self.noteID)
def check_password(self, password):
row = self.DB.select_one(self.noteID,[self.password])
actual_password = row[0]
if actual_password != None:
actual_password = str(actual_password)
if password != None and str(password) == actual_password:
return True
return False
def set_password(self,new_pass):
return self.DB.update(self.noteID,[self.password],[new_pass])
def is_locked(self):
row = self.DB.select_one(self.noteID,[self.password])
password = row[0]
if password==None or len(str(password)) == 0:
return False
else:
return True
示例3: authenticate
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import update [as 別名]
def authenticate(args):
"""
Authenticate application with oAuth2
"""
db = DB(args.token)
print "Authentication"
# read oAuth credentials
if db.oauth_client_id is None or db.oauth_client_secret is None:
# read oAuth details
client_id = raw_input("oAuth Client ID: ")
client_secret = getpass.getpass("oAuth Secret: ")
# save into database
db.update("oauth_client_id", client_id)
db.update("oauth_client_secret", client_secret)
db.save()
token = gdata.gauth.OAuth2Token(
client_id=db.oauth_client_id,
client_secret=db.oauth_client_secret,
scope=SCOPE,
user_agent=APP_ID
)
print token.generate_authorize_url()
code = raw_input('Enter verification code: ').strip()
# save into database
db.update("oauth_access_token", token.get_access_token(code).access_token)
db.update("oauth_refresh_token", token.refresh_token)
db.save()
print "You're successfully authenticated"
示例4: drop
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import update [as 別名]
def drop():
sql = 'DELETE FROM article WHERE code=%s'
DB.update(sql, 'hx')
示例5: drop
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import update [as 別名]
def drop(self):
sql = 'DELETE FROM article WHERE code=%s'
DB.update(sql, 'zdrb')
示例6: __init__
# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import update [as 別名]
class CalendarLog:
#Database names
database = "CALENDAR"
entry_id = "id"
data = "data"
date= "date"
password = "password"
#Actual log ID
logID = None
def __init__(self,logID):
self.DB = DB(self.database, self.entry_id)
self.logID = logID
def logID(self):
return logID
def index(self):
return self.DB.select_all([self.entry_id ,self.date],None,None,None)
def select_log(self):
row = self.DB.select_one(self.logID, [self.data, self.date])
return row
def select_logs_range(self,start,end,limit):
if start and end:
return self.DB.select_all([self.entry_id ,self.date, self.data],[self.date+" >=", "AND "+self.date+" <="],[start,end],limit)
elif start:
return self.DB.select_all([self.entry_id ,self.date, self.data],[self.date+" >="],[start],limit)
elif end:
return self.DB.select_all([self.entry_id ,self.date, self.data],[self.date+" <="],[end],limit)
else:
return self.DB.select_all([self.entry_id ,self.date, self.data],None,None,limit)
def update_log(self, text):
return self.DB.update(self.logID,[self.data],[text])
def update_log_date(self,date):
return self.DB.update(self.logID,[self.date],[date])
def add_log(self,text,date):
return self.DB.insert([self.data,self.date,self.password],[text,date,None])
def remove_log(self):
return self.DB.remove(self.logID)
def check_password(self, password):
row = self.DB.select_one(self.logID,[self.password])
actual_password = row[0]
if actual_password != None:
actual_password = str(actual_password)
if password != None and str(password) == actual_password:
return True
return False
def set_password(self,new_pass):
return self.DB.update(self.logID,[self.password],[new_pass])
def is_locked(self):
row = self.DB.select_one(self.logID,[self.password])
password = row[0]
if password==None or len(str(password)) == 0:
return False
else:
return True