【问题标题】:No data in my postgres DB even though it exists我的 postgres 数据库中没有数据,即使它存在
【发布时间】:2022-08-11 17:31:54
【问题描述】:

我在远程 ubuntu 服务器上有一个 PostgreSQL 数据库。 我的 Python 脚本能够使用这些配置写入数据库。

def get_query(group_name , heb_sale_rent ,heb_street, heb_city , heb_rooms , heb_size , heb_floor , heb_porch , heb_storage , heb_mamad , heb_parking , heb_elevator , heb_phone , heb_price):
    conn = psycopg2.connect(database=\'my_db\', host=\'192.168.72.130\', port=\'5432\', user=\'sql_user\', password=\'sql_user\')
    cur = conn.cursor()
    cur.execute(\"SELECT * FROM to_excel\")
    query = cur.fetchall()
    print(query)

#Result of print - [(\'1\', \'Karin\', \'מכירה, השכרה\', \'רחוב, ברובע\', \'שכונת, בסמטאות\', \'חדרים\', \'מ״ר, מ\"ר\', \'קומה\', \'מרפסת\', \'מחסן\', \'ממד, ממ״ד\', \'חניה, חנייה, חניית, חנית\', \'מעלית\', \'054, 052, 053\', \'מחיר, מבקשים\', \'2020-01-01\')]

我可以看到有数据,因为它打印出查询,但是当我连接到 ubuntu 上的数据库时,没有表行......太奇怪了。有谁知道问题可能是什么?

  • psql 中的命令不应该以分号结尾吗? -> 表 to_excel;或尝试 -> select * from to_excel;
  • 哦,伙计......我不相信是这样......谢谢你,我现在要去角落里哭了

标签: python django postgresql


【解决方案1】:

在命令末尾使用分号!!!!!!!!!!!!!!!

【讨论】:

    【解决方案2】:

    兄弟,在 psql 命令的末尾添加分号:D

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-23
      • 2019-11-11
      • 2013-11-04
      • 1970-01-01
      • 1970-01-01
      • 2017-09-24
      • 2020-12-01
      • 2011-09-21
      相关资源
      最近更新 更多