2 Star 4 Fork 1

IntelligenceVision / Face-VectorDB-Login

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
pgsql_conn.py 700 Bytes
一键复制 编辑 原始数据 按行查看 历史
代码阿尔法 提交于 2023-12-27 15:51 . some update
# PostgreSQL连接
# 创建人:曾逸夫
# 创建时间:2023-12-27
import psycopg
import os
import yaml
from pgvector.psycopg import register_vector
# 数据库连接
def get_db_connection():
current_path = os.path.abspath(os.path.dirname(__file__))
with open(current_path + "/pgsql_config.yaml", "r") as f:
pgsql_config = yaml.safe_load(f.read())
conn = psycopg.connect(
host=pgsql_config["host"],
dbname=pgsql_config["dbname"],
user=pgsql_config["username"],
password=pgsql_config["password"],
)
conn.execute("CREATE EXTENSION IF NOT EXISTS vector")
register_vector(conn)
return conn
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/intelligence-vision/face-vectordb-login.git
git@gitee.com:intelligence-vision/face-vectordb-login.git
intelligence-vision
face-vectordb-login
Face-VectorDB-Login
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891