2024-10-03 01:53:37 +00:00
|
|
|
import tqdm
|
2024-07-19 00:04:51 +00:00
|
|
|
|
2024-10-03 01:53:37 +00:00
|
|
|
from .typesense_client import client
|
2024-07-19 00:04:51 +00:00
|
|
|
|
2024-10-03 01:53:37 +00:00
|
|
|
def documents_to_database(documents_list, os_client=client):
|
|
|
|
try:
|
|
|
|
for document in tqdm.tqdm(documents_list.to_dict(orient='records')):
|
|
|
|
os_client.collections['social_media_posts'].documents.create(document)
|
|
|
|
print(f"Successfully inserted {len(documents_list)} documents.")
|
|
|
|
except Exception as e:
|
|
|
|
print(f"Error inserting documents: {str(e)}")
|