• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python cursor.execute函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.cursor.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了execute函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, certificates_instance, event_id):
        super(AddClientDialog,self).__init__()
        self.setWindowTitle(u"Adicionar cliente")

        self.event_id = event_id
        self.certificates_instance = certificates_instance

        cursor.execute("SELECT * FROM clients ORDER BY name ASC")
        self.clients = cursor.fetchall()

        self.mainLayout = QtGui.QVBoxLayout()

        self.titleLabel = QtGui.QLabel(u"Selecione um cliente")
        self.titleLabel.setFont(titleFont)

        self.clientsList = QtGui.QComboBox()
        for client in self.clients:
            self.clientsList.addItem(unicode(client[1]))

        self.saveBtn = QtGui.QPushButton(u"Selecionar")
        self.saveBtn.clicked.connect(self.add_client)

        self.mainLayout.addWidget(self.titleLabel)
        self.mainLayout.addWidget(self.clientsList)
        self.mainLayout.addWidget(self.saveBtn)

        self.setLayout(self.mainLayout)
开发者ID:helioloureiro,项目名称:certificate_generator,代码行数:27,代码来源:certificates.py


示例2: remove_client

    def remove_client(self):
        """
            Remove a client from the event's subscriptions.
        """

        # If there is a client selected, removes it.
        # If there is not, shows up an error message.
        try:
            current_subscription = self.subscriptionList.currentRow()
            subscription_id = self.clients[current_subscription][0]
            # Asks if the user really wants to remove the client
            choice = QtGui.QMessageBox.question(
                self, u"Apagar inscrição",
                u"Tem certeza que deseja apagar esta inscrição?",
                QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
            )
            if choice == QtGui.QMessageBox.Yes:
                cursor.execute(
                    "DELETE FROM subscriptions WHERE id=?",
                    str(subscription_id)
                )
                conn.commit()
            else:
                pass
            self.load_list()
        except IndexError:
            self.errorMsg.setText(u"Selecione um cliente existente!")
开发者ID:anderson89marques,项目名称:certificate_generator,代码行数:27,代码来源:certificates.py


示例3: load_table

    def load_table(self):
        self.clientsTable.clear()

        cursor.execute("SELECT * FROM clients")
        data = cursor.fetchall()

        if len(data) < 10:
            self.clientsTable.setRowCount(10)
        else:
            self.clientsTable.setRowCount(len(data))
        self.clientsTable.setColumnCount(4)
        self.clientsTable.setHorizontalHeaderLabels((u"ID",
                                                    u"Nome Completo",
                                                    u"E-mail",
                                                    u"CPF"))
        self.clientsTable.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
        self.clientsTable.verticalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
        r,c=0,0
        for item in data:
            for i in range(4):
                newitem = QtGui.QTableWidgetItem(unicode(item[i]))
                self.clientsTable.setItem(r,c,newitem)
                c += 1
            r += 1
            c = 0
开发者ID:DiSiqueira,项目名称:certificate_generator,代码行数:25,代码来源:clients.py


示例4: remove_event

    def remove_event(self):
        """
            Delete an existing event.
        """
        # Verifies if there is a selected event
        try:
            # Gets the event id
            r = self.eventsTable.currentRow()
            event_id = self.eventsTable.item(r, 0).text()

            # Asks if the user really wants to remove the event
            choice = QtGui.QMessageBox.question(
                self, u"Apagar evento",
                u"Tem certeza que deseja apagar este evento?",
                QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
            )
            if choice == QtGui.QMessageBox.Yes:
                cursor.execute("DELETE FROM events WHERE id=?", str(event_id))
                conn.commit()
            else:
                pass

            # Updates the events table
            self.load_table()
        except AttributeError:
            self.errorMsg.setText(u"Selecione um registro existente!")
开发者ID:anderson89marques,项目名称:certificate_generator,代码行数:26,代码来源:events.py


示例5: remove_signature

    def remove_signature(self):
        """
            Delete an existing signature.
        """
        # Verifies if there is a selected signature
        try:
            # Gets the selected signature id
            sig_id = self.signatures[self.signaturesList.currentRow()][0]

            # Asks if the user really wants to delete the signature
            choice = QtGui.QMessageBox.question(
                self, u"Apagar assinatura",
                u"Tem certeza que deseja apagar esta assinatura?",
                QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
            )

            if choice == QtGui.QMessageBox.Yes:
                os.remove(os.path.join(app_dir, "signatures",
                                       "{0}.png".format(str(sig_id))))
                cursor.execute(
                    "DELETE FROM signatures WHERE id=?",
                    (str(sig_id),)
                )
                conn.commit()
            else:
                pass

            # Updates the signatures list
            self.load_list()
        except IndexError:
            self.errorMsg.setText(u"Selecione um registro existente!")
开发者ID:juliarizza,项目名称:certificate_generator,代码行数:31,代码来源:institution.py


示例6: load_list

    def load_list(self):
        """
            Loads all subscriptions of the selected event
            and insert them in the subscriptionList widget.
        """

        # Get the subscripted clients
        if self.events:
            cursor.execute(
                "SELECT id,client_id FROM subscriptions WHERE event_id=?",
                str(self.events[self.eventsList.currentIndex()][0])
            )
            self.clients = cursor.fetchall()
        else:
            self.clients = []

        # Clears the widget to insert updated info
        self.subscriptionList.clear()

        # Select all subscripted clients and add them
        # to the subscriptionList widget
        for client in self.clients:
            cursor.execute(
                "SELECT name FROM clients WHERE id=?",
                str(client[1])
            )
            client_name = cursor.fetchone()
            if client:
                self.subscriptionList.addItem(unicode(client_name[0]))
开发者ID:anderson89marques,项目名称:certificate_generator,代码行数:29,代码来源:certificates.py


示例7: load_table

    def load_table(self):
        self.eventsTable.clear()

        cursor.execute("SELECT * FROM events ORDER BY id DESC")
        data = cursor.fetchall()

        if len(data) < 10:
            self.eventsTable.setRowCount(10)
        else:
            self.eventsTable.setRowCount(len(data))
        self.eventsTable.setColumnCount(4)
        self.eventsTable.setHorizontalHeaderLabels((u"ID",
                                                    u"Título",
                                                    u"Data de Início",
                                                    u"Data de Término"))
        self.eventsTable.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
        self.eventsTable.verticalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
        r,c=0,0
        for item in data:
            for i in range(4):
                newitem = QtGui.QTableWidgetItem(unicode(item[i]))
                self.eventsTable.setItem(r,c,newitem)
                c += 1
            r += 1
            c = 0
开发者ID:helioloureiro,项目名称:certificate_generator,代码行数:25,代码来源:events.py


示例8: generate

    def generate(self):
        if len(self.clients) == 0:
            self.errorMsg.setText(u"Primeiro inscreva clientes!")
        else:
            self.save_folder = QtGui.QFileDialog.getExistingDirectory(None,
                                                                u"Salvar em")

            self.cert_data = {"event": unicode(self.events[self.eventsList.currentIndex()][1]).upper(),
                         "start_date": unicode(self.events[self.eventsList.currentIndex()][2]),
                         "end_date": unicode(self.events[self.eventsList.currentIndex()][3]),
                         "hours": unicode(self.events[self.eventsList.currentIndex()][4]),
                         "content": unicode(self.events[self.eventsList.currentIndex()][5]).upper(),
                         "responsible_sig": unicode(self.signatures[self.responsibleList.currentIndex()][0]),
                         "institution_sig": unicode(self.signatures[self.institutionList.currentIndex()][0]),
                         "role": unicode(self.signatures[self.institutionList.currentIndex()][2]),
                         "institution": unicode(self.Config.get("Main","Name")).upper(),
                         "inst_register": unicode(self.Config.get("Main","ID"))}

            for client in self.clients:
                cursor.execute("SELECT name,register FROM clients WHERE id=?",str(client[1]))
                client_data = cursor.fetchone()
                self.cert_data["name"] = unicode(client_data[0]).upper()
                self.cert_data["register"] = unicode(client_data[1])
                generate_certificate(self.save_folder, self.cert_data)

            cursor.execute("SELECT * FROM signatures WHERE id=?",
                           str(self.signatures[self.responsibleList.currentIndex()][0]))
            responsible = cursor.fetchone()
            self.cert_data["name"] = unicode(responsible[1]).upper()
            self.cert_data["register"] = unicode(responsible[4]).upper()
            generate_certificate_responsible(self.save_folder, self.cert_data)
开发者ID:DiSiqueira,项目名称:certificate_generator,代码行数:31,代码来源:certificates.py


示例9: run

    def run(self):
        self.mailer = Mailer()
        self.mailer.connect()
        self.emit(QtCore.SIGNAL("update"),1,0)

        n = 1
        for client in self.clients:
            cursor.execute("SELECT name,email FROM clients WHERE id=?",str(client[1]))
            client_data = cursor.fetchone()

            filepath = os.path.join(unicode(self.save_folder),u''.join(i for i in \
                                                                unicode(client_data[0]) \
                                                                if ord(i)<128)\
                                                                .upper()\
                                                                .replace(" ",""))
            filepath += ".pdf"

            self.cert_data["name"] = unicode(client_data[0]).upper()
            self.cert_data["register"] = unicode(client_data[1])

            self.emit(QtCore.SIGNAL("update"),2,n)
            generate_certificate(self.save_folder, self.cert_data)
            self.mailer.send_certificate(filepath,unicode(client_data[1]))
            n+=1

        filepath = os.path.join(unicode(self.save_folder),u"responsible.pdf")
        self.cert_data["name"] = unicode(self.responsible[1]).upper()
        self.cert_data["register"] = unicode(self.responsible[4]).upper()
        self.emit(QtCore.SIGNAL("update"),3,0)
        generate_certificate_responsible(self.save_folder, self.cert_data)
        self.mailer.send_certificate(unicode(filepath),unicode(self.responsible[3]))

        self.emit(QtCore.SIGNAL("update"),4,0)
        self.mailer.quit()
开发者ID:helioloureiro,项目名称:certificate_generator,代码行数:34,代码来源:certificates.py


示例10: load_list

    def load_list(self):
        self.signaturesList.clear()

        cursor.execute("SELECT * FROM signatures")
        self.signatures = cursor.fetchall()

        for sig in self.signatures:
            self.signaturesList.addItem(sig[1])
开发者ID:itjp,项目名称:certificate_generator,代码行数:8,代码来源:institution.py


示例11: load_list

    def load_list(self):
        self.signaturesList.clear()

        cursor.execute("SELECT * FROM signatures ORDER BY name ASC")
        self.signatures = cursor.fetchall()

        for sig in self.signatures:
            self.signaturesList.addItem(unicode(sig[1]))
开发者ID:helioloureiro,项目名称:certificate_generator,代码行数:8,代码来源:institution.py


示例12: add_client

 def add_client(self):
     cursor.execute("INSERT INTO subscriptions VALUES (NULL,?,?)",
                   (
                   str(self.event_id),
                   str(self.clients[self.clientsList.currentIndex()][0])
                   ))
     conn.commit()
     self.certificates_instance.load_list()
     self.hide()
开发者ID:helioloureiro,项目名称:certificate_generator,代码行数:9,代码来源:certificates.py


示例13: __init__

    def __init__(self, clients_list_instance, client_id=None):
        super(ClientDialog,self).__init__()
        self.setGeometry(450,300,400,200)
        self.clients_list_instance = clients_list_instance

        self.client_id = client_id

        self.mainLayout = QtGui.QVBoxLayout()
        self.formLayout = QtGui.QFormLayout()

        self.clientName = QtGui.QLabel(u"Nome completo", self)
        self.clientNameLineEdit = QtGui.QLineEdit(self)
        self.clientNameLineEdit.setPlaceholderText(u"Ex: Fulano da Silva")
        self.formLayout.addRow(self.clientName, self.clientNameLineEdit)

        self.clientEmail = QtGui.QLabel(u"E-mail", self)
        self.clientEmailLineEdit = QtGui.QLineEdit(self)
        self.clientEmailLineEdit.setPlaceholderText(u"Ex: [email protected]")
        self.formLayout.addRow(self.clientEmail, self.clientEmailLineEdit)

        self.clientRegister = QtGui.QLabel(u"CPF", self)
        self.clientRegisterLineEdit = QtGui.QLineEdit(self)
        self.clientRegisterLineEdit.setInputMask(u"999.999.999-99") ## Brazil CPF
        self.formLayout.addRow(self.clientRegister, self.clientRegisterLineEdit)

        self.errorMsg = QtGui.QLabel(u"",self)
        self.errorMsg.setStyleSheet("color: red; font-weight: bold;")

        self.saveBtn = QtGui.QPushButton(u"Salvar")
        self.saveBtn.clicked.connect(self.save_data)

        if self.client_id:
            self.setWindowTitle(u"Editar cliente")
            self.titleLabel = QtGui.QLabel(u"Editar cliente", self)
            self.titleLabel.setFont(titleFont)

            cursor.execute("SELECT * FROM clients WHERE id=?", str(self.client_id))
            data = cursor.fetchone()

            self.clientNameLineEdit.setText(unicode(data[1]))
            self.clientEmailLineEdit.setText(unicode(data[2]))
            self.clientRegisterLineEdit.setText(unicode(data[3]))
        else:
            self.setWindowTitle(u"Cadastrar cliente")
            self.titleLabel = QtGui.QLabel(u"Cadastrar cliente", self)
            self.titleLabel.setFont(titleFont)

        self.mainLayout.addWidget(self.titleLabel)
        self.mainLayout.addLayout(self.formLayout)
        self.mainLayout.addWidget(self.errorMsg)
        self.mainLayout.addWidget(self.saveBtn)

        self.setLayout(self.mainLayout)
开发者ID:DiSiqueira,项目名称:certificate_generator,代码行数:53,代码来源:clients.py


示例14: generate_send

    def generate_send(self):
        self.generate_general()

        cursor.execute("SELECT * FROM signatures WHERE id=?",
                       str(self.signatures[self.responsibleList.currentIndex()][0]))
        responsible = cursor.fetchone()

        self.generate_send_progress = GenerateSendProgress(self.save_folder,
                                                           self.cert_data,
                                                           self.clients,
                                                           responsible
                                                          )
        self.generate_send_progress.show()
开发者ID:helioloureiro,项目名称:certificate_generator,代码行数:13,代码来源:certificates.py


示例15: load_list

    def load_list(self):
        if self.events:
            cursor.execute("SELECT id,client_id FROM subscriptions WHERE event_id=?",
                            str(self.events[self.eventsList.currentIndex()][0]))
            self.clients = cursor.fetchall()
        else:
            self.clients = []

        self.subscriptionList.clear()
        for client in self.clients:
            cursor.execute("SELECT name FROM clients WHERE id=?",str(client[1]))
            client_name = unicode(cursor.fetchone()[0])
            self.subscriptionList.addItem(client_name)
开发者ID:DiSiqueira,项目名称:certificate_generator,代码行数:13,代码来源:certificates.py


示例16: load_list

    def load_list(self):
        """
            Updates the list widget with the signatures data.
        """

        # Clear the list widget to add new data
        self.signaturesList.clear()

        # Select all signatures
        cursor.execute("SELECT * FROM signatures ORDER BY name ASC")
        self.signatures = cursor.fetchall()

        # Add all signatures to the list widget
        for sig in self.signatures:
            self.signaturesList.addItem(unicode(sig[1]))
开发者ID:juliarizza,项目名称:certificate_generator,代码行数:15,代码来源:institution.py


示例17: remove_signature

 def remove_signature(self):
     try:
         sig_id = self.signatures[self.signaturesList.currentRow()][0]
         choice = QtGui.QMessageBox.question(self, "Apagar assinatura",
         "Tem certeza que deseja apagar esta assinatura?",
         QtGui.QMessageBox.Yes |
         QtGui.QMessageBox.No)
         if choice == QtGui.QMessageBox.Yes:
             cursor.execute("DELETE FROM signatures WHERE id=?", str(sig_id))
             conn.commit()
         else:
             pass
         self.load_list()
     except IndexError:
         self.errorMsg.setText("Selecione um registro existente!")
开发者ID:itjp,项目名称:certificate_generator,代码行数:15,代码来源:institution.py


示例18: remove_client

 def remove_client(self):
     try:
         subscription_id = self.clients[self.subscriptionList.currentRow()][0]
         choice = QtGui.QMessageBox.question(self, u"Apagar inscrição",
                                             u"Tem certeza que deseja apagar esta inscrição?",
                                             QtGui.QMessageBox.Yes |
                                             QtGui.QMessageBox.No)
         if choice == QtGui.QMessageBox.Yes:
             cursor.execute("DELETE FROM subscriptions WHERE id=?",
                             str(subscription_id))
             conn.commit()
         else:
             pass
         self.load_list()
     except IndexError:
         self.errorMsg.setText(u"Selecione um cliente existente!")
开发者ID:helioloureiro,项目名称:certificate_generator,代码行数:16,代码来源:certificates.py


示例19: remove_client

 def remove_client(self):
     try:
         r = self.clientsTable.currentRow()
         client_id = self.clientsTable.item(r,0).text()
         choice = QtGui.QMessageBox.question(self, u"Apagar cliente",
                                             u"Tem certeza que deseja apagar este cliente?",
                                             QtGui.QMessageBox.Yes |
                                             QtGui.QMessageBox.No)
         if choice == QtGui.QMessageBox.Yes:
             cursor.execute("DELETE FROM clients WHERE id=?", str(client_id))
             conn.commit()
         else:
             pass
         self.load_table()
     except AttributeError:
         self.errorMsg.setText(u"Selecione um registro existente!")
开发者ID:DiSiqueira,项目名称:certificate_generator,代码行数:16,代码来源:clients.py


示例20: save_data

 def save_data(self):
     """
         Saves the event data.
     """
     # Verifies if all fields are filled
     if unicode(self.eventTitleLineEdit.text()) == "":
         self.errorMsg.setText(u"O título precisa ser preenchido!")
     elif len(unicode(self.eventStartDateLineEdit.text())) < 10 or \
             len(unicode(self.eventEndDateLineEdit.text())) < 10:
         self.errorMsg.setText(u"As datas precisam estar \
                               em um formato xx/xx/xxxx!")
     elif unicode(self.eventHoursLineEdit.text()) == "":
         self.errorMsg.setText(u"As horas precisam ser um inteiro!")
     else:
         if self.event_id:
             # Updates the record if it is an existing event
             cursor.execute(
                 "UPDATE events SET title=?, start_date=?, end_date=?, \
                 hours=?, content=? WHERE id=?",
                 (
                     unicode(self.eventTitleLineEdit.text()),
                     unicode(self.eventStartDateLineEdit.text()),
                     unicode(self.eventEndDateLineEdit.text()),
                     unicode(self.eventHoursLineEdit.text()),
                     unicode(self.eventContentTextEdit.toPlainText()),
                     str(self.event_id)
                 )
             )
         else:
             # Register the event
             cursor.execute(
                 "INSERT INTO events VALUES (NULL,?,?,?,?,?)",
                 (
                     unicode(self.eventTitleLineEdit.text()),
                     unicode(self.eventStartDateLineEdit.text()),
                     unicode(self.eventEndDateLineEdit.text()),
                     unicode(self.eventHoursLineEdit.text()),
                     unicode(self.eventContentTextEdit.toPlainText())
                 )
             )
         # Saves the database
         conn.commit()
         # Update the table
         self.events_list_instance.load_table()
         # Hide the dialog
         self.hide()
开发者ID:anderson89marques,项目名称:certificate_generator,代码行数:46,代码来源:events.py



注:本文中的models.cursor.execute函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python dao.Dao类代码示例发布时间:2022-05-27
下一篇:
Python courses.Workflow类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap