66f7db40b0
Three FastAPI backends comparing PostgreSQL/pgvector and Oracle 26ai for semantic image search using CLIP embeddings: Python-side embedding for both databases, plus Oracle in-database embedding via VECTOR_EMBEDDING(CLIP_TXT). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
20 lines
545 B
Python
20 lines
545 B
Python
import os
|
|
import oracledb
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
def get_connection():
|
|
return oracledb.connect(
|
|
user=os.getenv("ORA_USER"),
|
|
password=os.getenv("ORA_PASSWORD"),
|
|
dsn=f"{os.getenv('ORA_HOST')}:{os.getenv('ORA_PORT')}/{os.getenv('ORA_SERVICE')}",
|
|
)
|
|
|
|
def get_connection_indb():
|
|
return oracledb.connect(
|
|
user=os.getenv("ORA_USER_INDB"),
|
|
password=os.getenv("ORA_PASSWORD_INDB"),
|
|
dsn=f"{os.getenv('ORA_HOST')}:{os.getenv('ORA_PORT')}/{os.getenv('ORA_SERVICE')}",
|
|
)
|