You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
534 B
21 lines
534 B
|
2 weeks ago
|
from sqlalchemy import create_engine, text
|
||
|
|
from sentence_transformers import SentenceTransformer
|
||
|
|
import os
|
||
|
|
|
||
|
|
DATABASE_URL = os.getenv("DATABASE_URL")
|
||
|
|
engine = create_engine(DATABASE_URL)
|
||
|
|
|
||
|
|
model = SentenceTransformer("all-MiniLM-L6-v2")
|
||
|
|
|
||
|
|
name = "Range"
|
||
|
|
embedding = model.encode(name).tolist()
|
||
|
|
|
||
|
|
with engine.connect() as conn:
|
||
|
|
conn.execute(text("""
|
||
|
|
INSERT INTO attributes (name, embedding)
|
||
|
|
VALUES (:name, :embedding)
|
||
|
|
"""), {"name": name, "embedding": embedding})
|
||
|
|
conn.commit()
|
||
|
|
|
||
|
|
print("Inserted successfully")
|