nullHawk commited on
Commit
3f1d954
·
verified ·
1 Parent(s): 2f9fb02

feat: db query

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -2,19 +2,24 @@ from huggingface_hub import hf_hub_download
2
  from gensim.models import Word2Vec
3
 
4
  import faiss
 
5
 
6
  import streamlit as st
7
  import pandas as pd
8
  import dask.dataframe as dd
9
 
10
  @st.cache_data
11
- def get_dask_df(df_path='bin/data.parquet'):
12
- return dd.read_parquet(df_path)
13
 
14
 
15
- @st.cache_data
16
- def query_rows(rows: list):
17
- df = get_dask_df()
 
 
 
 
18
 
19
  @st.cache_data
20
  def get_model():
 
2
  from gensim.models import Word2Vec
3
 
4
  import faiss
5
+ import duckdb
6
 
7
  import streamlit as st
8
  import pandas as pd
9
  import dask.dataframe as dd
10
 
11
  @st.cache_data
12
+ def get_db(path='arxiv.db'):
13
+ con = duckdb.connect(path)
14
 
15
 
16
+ def query_neighbours(rows: list):
17
+ con = get_db()
18
+ placeholders = ",".join("?" for _ in rows)
19
+ return con.execute(
20
+ f"SELECT * FROM arxiv WHERE column0 IN ({placeholders})",
21
+ rows,
22
+ ).fetchall()
23
 
24
  @st.cache_data
25
  def get_model():