File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 44import logging
55import os
66
7+ import numpy as np
78import sqlalchemy .exc
89from dotenv import load_dotenv
910from sqlalchemy import select , text
@@ -41,8 +42,11 @@ async def seed_data(engine):
4142 if db_item .scalars ().first ():
4243 continue
4344 attrs = {key : value for key , value in seed_data_object .items ()}
44- row = Item (** attrs )
45- session .add (row )
45+ attrs ["embedding_ada002" ] = np .array (seed_data_object ["embedding_ada002" ])
46+ attrs ["embedding_nomic" ] = np .array (seed_data_object ["embedding_nomic" ])
47+ column_names = ", " .join (attrs .keys ())
48+ values = ", " .join ([f":{ key } " for key in attrs .keys ()])
49+ await session .execute (text (f"INSERT INTO { table_name } ({ column_names } ) VALUES ({ values } )" ), attrs )
4650 try :
4751 await session .commit ()
4852 except sqlalchemy .exc .IntegrityError :
You can’t perform that action at this time.
0 commit comments