gpt4 book ai didi

Python 3.4 -> 使用 SQLAlchemy win32 连接到 PostGres SQL

转载 作者:行者123 更新时间:2023-11-29 13:25:30 24 4
gpt4 key购买 nike

我正在使用 Postgres 和 Pandas,但在连接两者时遇到了问题。我已经使用 SQLAlchemy 创建了 enginestr,如下所示

from sqlalchemy import create_engine
engine = create_engine('postgresql://postgres:password@localhost:5432/bilal')

但是,当我运行该语句时,出现以下错误

ImportError : No module names 'psycopg2'

我已经尝试安装该模块,但没有成功。是因为我使用的是 32 位 Windows 机器吗?

谢谢,

比拉尔

最佳答案

你安装正确了吗?使用此链接下载并安装它 win-psycopg或者使用 pip install psycopg2

您可以在连接字符串中指定它:

from sqlalchemy import create_engine

engine = create_engine('postgresql+psycopg2://postgres:password@localhost/bilal')

关于Python 3.4 -> 使用 SQLAlchemy win32 连接到 PostGres SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34643257/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com