【发布时间】: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