微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

sqlalchemy,尝试连接到本地数据库

如何解决sqlalchemy,尝试连接到本地数据库

我有点知道,所以我不知道如何找到解决此类错误方法。正在尝试连接到本地数据库

from sqlalchemy import create_engine

rds_connection_string = "postgres:password@localhost:5432/ETL_DATABASES"
engine = create_engine(f'postgresql://{rds_connection_string}')

并得到:

--------------------------------------------------------------------------- ImportError                               Traceback (most recent call last) <ipython-input-12-db09b1b74d73> in <module>
      1 rds_connection_string = "postgres:password@localhost:5432/ETL_DATABASES"
----> 2 engine = create_engine(f'postgresql://{rds_connection_string}')
/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/__init__.py in create_engine(*args,**kwargs)
    498     strategy = kwargs.pop("strategy",default_strategy)
    499     strategy = strategies.strategies[strategy]
--> 500     return strategy.create(*args,**kwargs)
    501 
    502 
/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py in create(self,name_or_url,**kwargs)
     85                 if k in kwargs:
     86                     dbapi_args[k] = pop_kwarg(k)
---> 87             dbapi = dialect_cls.dbapi(**dbapi_args)
     88 
     89         dialect_args["dbapi"] = dbapi
/opt/anaconda3/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py in dbapi(cls)
    776     @classmethod
    777     def dbapi(cls):
--> 778         import psycopg2
    779 
    780         return psycopg2
/opt/anaconda3/lib/python3.8/site-packages/psycopg2/__init__.py in <module>
     49 # Import the DBAPI-2.0 stuff into top-level module.
     50 
---> 51 from psycopg2._psycopg import (                     # noqa
     52     BINARY,NUMBER,STRING,DATETIME,ROWID,53 
ImportError: dlopen(/opt/anaconda3/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so,2): Symbol not found: _PQencryptPasswordConn   
Referenced from: /opt/anaconda3/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so 
Expected in: /usr/lib/libpq.5.6.dylib  in /opt/anaconda3/lib/python3.8/site-packages/psycopg2/_psycopg.cpython-38-darwin.so

我在 jupyter notebook 中,并且在 sql 部分使用 pg Admin 4

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。