且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用SQLAlchemy通过Unix套接字连接到数据库

更新时间:2022-11-30 09:42:58

此处所需的特殊关键字是主机

The special keyword needed here is host:

DATABASE_URL=postgres://user:password@/dbname?host=/path/to/db

请注意,主机中的路径应该是路径,而不是套接字文件本身(psycopg2假定套接字具有标准命名约定 .s.PGSQL.5432

Note that the path in host should be a path, not the socket file itself (psycopg2 assumes the socket has the standard naming convention .s.PGSQL.5432)

https://docs.sqlalchemy.org/en/latest/dialects/postgresql.html#unix -domain-connections