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


Python database.DataBase類代碼示例

本文整理匯總了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(
					     '<', '&lt;').replace('>', '&gt;')
        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
開發者ID:dibyendu,項目名稱:WayToSms,代碼行數:27,代碼來源:history.py

示例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
開發者ID:dibyendu,項目名稱:WayToSms,代碼行數:26,代碼來源:interface.py

示例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'})
開發者ID:mohan5v5988,項目名稱:Python,代碼行數:7,代碼來源:Web.py

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

示例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]))
開發者ID:rbistolfi,項目名稱:gps-tracking,代碼行數:56,代碼來源:classCategoryParam.py

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

示例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)
開發者ID:dibyendu,項目名稱:WayToSms,代碼行數:10,代碼來源:account.py

示例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))
開發者ID:germanrs,項目名稱:calendario,代碼行數:10,代碼來源:calendario.py

示例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()
開發者ID:dibyendu,項目名稱:Plexicon,代碼行數:11,代碼來源:design.py

示例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
開發者ID:dibyendu,項目名稱:WayToSms,代碼行數:11,代碼來源:interface.py

示例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
開發者ID:dibyendu,項目名稱:WayToSms,代碼行數:11,代碼來源:interface.py

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

示例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()
開發者ID:acknowledge,項目名稱:NFCGolfBallDispenser-UI,代碼行數:12,代碼來源:action.py

示例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
開發者ID:dibyendu,項目名稱:WayToSms,代碼行數:12,代碼來源:account.py

示例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
開發者ID:dibyendu,項目名稱:WayToSms,代碼行數:12,代碼來源:history.py


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