1. <small id='wYnrL'></small><noframes id='wYnrL'>

    2. <legend id='wYnrL'><style id='wYnrL'><dir id='wYnrL'><q id='wYnrL'></q></dir></style></legend>
      • <bdo id='wYnrL'></bdo><ul id='wYnrL'></ul>

      1. <tfoot id='wYnrL'></tfoot>

        <i id='wYnrL'><tr id='wYnrL'><dt id='wYnrL'><q id='wYnrL'><span id='wYnrL'><b id='wYnrL'><form id='wYnrL'><ins id='wYnrL'></ins><ul id='wYnrL'></ul><sub id='wYnrL'></sub></form><legend id='wYnrL'></legend><bdo id='wYnrL'><pre id='wYnrL'><center id='wYnrL'></center></pre></bdo></b><th id='wYnrL'></th></span></q></dt></tr></i><div id='wYnrL'><tfoot id='wYnrL'></tfoot><dl id='wYnrL'><fieldset id='wYnrL'></fieldset></dl></div>

        如何从 qdateEdit 获取用户输入并从 postgres 的数据

        时间:2023-08-04

      2. <tfoot id='9Q3H3'></tfoot>
        <i id='9Q3H3'><tr id='9Q3H3'><dt id='9Q3H3'><q id='9Q3H3'><span id='9Q3H3'><b id='9Q3H3'><form id='9Q3H3'><ins id='9Q3H3'></ins><ul id='9Q3H3'></ul><sub id='9Q3H3'></sub></form><legend id='9Q3H3'></legend><bdo id='9Q3H3'><pre id='9Q3H3'><center id='9Q3H3'></center></pre></bdo></b><th id='9Q3H3'></th></span></q></dt></tr></i><div id='9Q3H3'><tfoot id='9Q3H3'></tfoot><dl id='9Q3H3'><fieldset id='9Q3H3'></fieldset></dl></div>
            <bdo id='9Q3H3'></bdo><ul id='9Q3H3'></ul>

                <tbody id='9Q3H3'></tbody>

              1. <small id='9Q3H3'></small><noframes id='9Q3H3'>

                <legend id='9Q3H3'><style id='9Q3H3'><dir id='9Q3H3'><q id='9Q3H3'></q></dir></style></legend>
                • 本文介绍了如何从 qdateEdit 获取用户输入并从 postgres 的数据库中选择它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想知道如何在 QDateEdit 中获取用户输入并在 postgres 的表格中选择它?这是我的代码

                  i want to know how to get the user input in QDateEdit and select it in a table in postgres? here is my code

                   def date(self):
                  
                          try:
                              date = self.dateEdit.date()
                              print(date)
                              conn = psycopg2.connect(dbname="sample", user="postgres", password="admin", host="localhost", port="5432")
                              cur = conn.cursor()
                              cur.execute("SELECT * FROM data WHERE stdate = '%s'",date)
                              result = cur.fetchall()
                              self.tableWidget.setRowCount(0)
                              for row_number, row_data in enumerate(result):
                                  self.tableWidget.insertRow(row_number)
                                  for column_number, data in enumerate(row_data):
                                      self.tableWidget.setItem(row_number, column_number, QTableWidgetItem(str(data)))
                          except Exception as e:
                              print("Error")
                  

                  这部分有问题

                  cur.execute("SELECT * FROM data WHERE stdate = '%s'",date)
                  

                  如何从 QDateEdit 获取日期并在 postgres 的表格中选择它?

                  how do i get the date from QDateEdit and select it in the table in postgres?

                  我只想选择标准日期等于用户在 QDateEdit 中输入的日期的行,并在我单击选择数据按钮时将其显示在 QtableView 中

                  and i only want to select the rows where the stdate is equal to the date that the user input in the QDateEdit and display it in the QtableView when i click the select data button

                  推荐答案

                  你必须:

                  • 使用 datetime.time() 而不是 QDate.
                  • 占位符不带引号.
                  dt = self.dateEdit.date().toPyDate()
                  cur.execute("SELECT * FROM data WHERE stdate = %s", (dt,))
                  

                  这篇关于如何从 qdateEdit 获取用户输入并从 postgres 的数据库中选择它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Pyinstaller 和 PyQt5 macOS Mojave 兼容性问题 下一篇:如何在 PyQT5 对话窗口中记录按下的组合键

                  相关文章

                  最新文章

                    <bdo id='U42NW'></bdo><ul id='U42NW'></ul>

                  <small id='U42NW'></small><noframes id='U42NW'>

                • <tfoot id='U42NW'></tfoot>
                  1. <i id='U42NW'><tr id='U42NW'><dt id='U42NW'><q id='U42NW'><span id='U42NW'><b id='U42NW'><form id='U42NW'><ins id='U42NW'></ins><ul id='U42NW'></ul><sub id='U42NW'></sub></form><legend id='U42NW'></legend><bdo id='U42NW'><pre id='U42NW'><center id='U42NW'></center></pre></bdo></b><th id='U42NW'></th></span></q></dt></tr></i><div id='U42NW'><tfoot id='U42NW'></tfoot><dl id='U42NW'><fieldset id='U42NW'></fieldset></dl></div>

                    1. <legend id='U42NW'><style id='U42NW'><dir id='U42NW'><q id='U42NW'></q></dir></style></legend>