rianders commited on
Commit
7be9f60
·
verified ·
1 Parent(s): 77b117f

Update database_utils.py

Browse files
Files changed (1) hide show
  1. database_utils.py +10 -0
database_utils.py CHANGED
@@ -1,4 +1,6 @@
1
  import sqlite3
 
 
2
 
3
  def init_db():
4
  conn = sqlite3.connect('embeddings.db')
@@ -26,3 +28,11 @@ def get_all_embeddings():
26
  embeddings = [np.frombuffer(row[1], dtype=np.float32).reshape(-1, 3) for row in data]
27
  sentences = [row[0] for row in data]
28
  return embeddings, sentences
 
 
 
 
 
 
 
 
 
1
  import sqlite3
2
+ import pandas as pd
3
+
4
 
5
  def init_db():
6
  conn = sqlite3.connect('embeddings.db')
 
28
  embeddings = [np.frombuffer(row[1], dtype=np.float32).reshape(-1, 3) for row in data]
29
  sentences = [row[0] for row in data]
30
  return embeddings, sentences
31
+
32
+
33
+ def fetch_data_as_csv():
34
+ conn = sqlite3.connect('embeddings.db')
35
+ query = "SELECT sentence, embedding FROM embeddings"
36
+ df = pd.read_sql_query(query, conn)
37
+ conn.close()
38
+ return df.to_csv(index=False)