本文整理汇总了Python中database.DataBase类的典型用法代码示例。如果您正苦于以下问题:Python DataBase类的具体用法?Python DataBase怎么用?Python DataBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DataBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __selection_change
def __selection_change(self, view):
'''
this method is called when a new
row in the tree view is selected
'''
rows = view.get_selection().get_selected()
message = rows[0].get_value(rows[1], 6).replace('&', '&').replace(
'<', '<').replace('>', '>')
receiver = rows[0].get_value(rows[1], 7).split(',')
database = DataBase()
receiver = database.get_contact_name(receiver)
sender = rows[0].get_value(rows[1], 8)
database.close()
self.message_store.clear()
self.message_scroll.show_all()
name = ''
number = ''
for receipient in receiver:
name += receipient[0] + '\n'
number += receipient[1] + '\n'
name = name[:-1]
number = number[:-1]
self.message_store.append(['<span font_desc="belgrano 12"><b>'
+ message + '</b></span>', number, name,
sender, '#3890FF'])
return
示例2: __check_send_status
def __check_send_status(self, button, status, receiver, message):
flag = True
for key in status.keys():
if not status[key][1]:
flag = False
break
if flag:
button.set_sensitive(True)
self.__spnnier.stop()
failure = []
for key in status.keys():
if not status[key][0]:
failure.append(key)
self.__generalize_status_bar()
if not failure:
self.__custom_status(True)
else:
self.__custom_status(False, failure)
for failed in failure:
receiver.remove(failed)
if receiver:
database = DataBase()
database.save_message(message, receiver, time_stamp())
database.close()
return False
return True
示例3: editEmp
def editEmp():
id = request.args.get('id', '')
print(request.json)
if not request.json:
abort(400)
DataBase.editEmp(id,Employee(0,request.json['Login'],request.json['Name'],Employee.hashPassword(request.json['Password']),request.json['Salary']))
return jsonify({'status':'good'})
示例4: _day_selected_cb
def _day_selected_cb(self, widget, data=None):
'''Select new day'''
date_formated = date_format(self.calendar.get_date())
db = DataBase(self.path)
data = db.get(date_formated)
db.close()
tasks_model = TasksModel(data)
self.tasks_list.set_model(tasks_model.get_model())
示例5: CategoryParam
class CategoryParam(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self)
self.categoryParam = Ui_CatParam()
self.categoryParam.setupUi(self)
self.showParam()
self.connect(self.categoryParam.btnSet,SIGNAL('clicked()'),self.setParam)
self.connect(self.categoryParam.btnDefault,SIGNAL('clicked()'),self.setDefault)
def setDefault(self):
conn = sqlite3.connect('dakar.sqlite')
cursor = conn.cursor()
query = "UPDATE category set minRange ='0' ,maxRange ='50' where id = 1"
cursor.execute(query)
query = "UPDATE category set minRange ='51' ,maxRange ='99' where id = 2"
cursor.execute(query)
query = "UPDATE category set minRange ='100' ,maxRange ='200' where id = 3"
cursor.execute(query)
conn.commit()
self.showParam()
def setParam(self):
conn = sqlite3.connect('dakar.sqlite')
cursor = conn.cursor()
minMoto = self.categoryParam.lnMinMoto.text()
maxMoto = self.categoryParam.lnMaxMoto.text()
minQuad = self.categoryParam.lnMinQuad.text()
maxQuad = self.categoryParam.lnMaxQuad.text()
minCar = self.categoryParam.lnMinCar.text()
maxCar = self.categoryParam.lnMaxCar.text()
query = "UPDATE category set minRange ='%i' ,maxRange ='%i' where id = 1"%(int(minMoto),int(maxMoto))
cursor.execute(query)
query = "UPDATE category set minRange ='%i' ,maxRange ='%i' where id = 2"%(int(minQuad),int(maxQuad))
cursor.execute(query)
query = "UPDATE category set minRange ='%i' ,maxRange ='%i' where id = 3"%(int(minCar),int(maxCar))
cursor.execute(query)
conn.commit()
self.showParam()
def showParam(self):
self.db = DataBase()
self.db.open('dakar.sqlite')
rows = self.db.get_category()
self.categoryParam.lnMinMoto.setText(str(rows[0][2]))
self.categoryParam.lnMaxMoto.setText(str(rows[0][3]))
self.categoryParam.lnMinQuad.setText(str(rows[1][2]))
self.categoryParam.lnMaxQuad.setText(str(rows[1][3]))
self.categoryParam.lnMinCar.setText(str(rows[2][2]))
self.categoryParam.lnMaxCar.setText(str(rows[2][3]))
示例6: _delete_row_cb
def _delete_row_cb(self, widget, data=None):
'''Delete a row'''
selection = self.tasks_list.get_selection()
model, row_iter = selection.get_selected()
row = model[row_iter]
data = (row[0],)
db = DataBase(self.path)
db.delete(data)
db.close()
self.get_tasks()
示例7: confirm_exit
def confirm_exit(unused):
'confirms whether to remove the only user'
from database import DataBase
import sys
database = DataBase()
database.drop_default()
database.close()
message.destroy()
sys.exit(0)
示例8: mark_day
def mark_day(self):
'''Mark the days of the month with tasks'''
date = date_format(self.calendar.get_date())
#just the month
data = (date[3:],)
db = DataBase(self.path)
day_list = db.get_days(data)
db.close()
for i in day_list:
self.calendar.mark_day(int(i))
示例9: __update_database
def __update_database(self, star, word):
'updates the database when a word is starred/unstarred'
from database import DataBase
import pickle
database = DataBase()
table = (len(word.query) > 1 and word.query[1] != ' ') and \
word.query[:2] or word.query[:1]
data = star.state == True and pickle.dumps(word) or None
database.update(table.lower(), (word.query.lower(), data, 'english'))
database.close()
示例10: re_log_in
def re_log_in(unused_widget, unused_event):
from way2sms import login
import time
database = DataBase()
user = database.get_default()
thread.start_new_thread(login, (str(user[0]), user[1], True))
database.close()
time.sleep(3.4)
self.__generalize_status_bar()
self.__push_status_message('<span font_desc="belgrano 10"><b> Try to <span foreground="#0000FF">re send</span> once more</b></span>')
return
示例11: __send_message
def __send_message(self, number, message, status):
from way2sms import send
import time
database = DataBase()
customer_id = database.get_default()[2]
for text in message:
text = text.strip()
status[number][0] = status[number][0] and send(customer_id, number, text)
time.sleep(1.4)
status[number][1] = True
return
示例12: get_tasks
def get_tasks(self):
'''Get the rows'''
date_formated = date_format(self.calendar.get_date())
db = DataBase(self.path)
data = db.get(date_formated)
reminder = db.get_reminder()
db.close()
tasks_model = TasksModel(data)
reminder_model = TasksModel(reminder)
self.tasks_list.set_model(tasks_model.get_model())
self.reminder_list.set_model(reminder_model.get_model())
示例13: __init__
def __init__(self, pifacecontrol):
"""! @brief Initialize the instance and get the two collections of the database.
@param self the Action instance
"""
QObject.__init__(self)
## contains a link to the database collection *user*
self.users = DataBase().user
## contains a link to the database collection *transaction*
self.transactions = DataBase().transaction
self.piFace = pifacecontrol
self.piFace.activateButtonListener()
示例14: __save
def __save(self, receiver, radio):
'saves the user informations'
for radio in radio.get_group():
if radio.get_active():
from database import DataBase
database = DataBase()
database.default_user(radio.get_label())
if type(receiver) != type(self):
self.hide_on_delete()
gtk.main_quit()
return False
示例15: marker
def marker(selected):
database = DataBase()
for index in range(32):
calendar.unmark_day(index)
for item in database.get_dates(selected):
calendar.mark_day(item[0])
database.close()
if selected[0] != self.__cur[2] or selected[1] + 1 != self.__cur[1]:
calendar.unmark_day(self.__cur[0])
else:
calendar.mark_day(self.__cur[0])
return