# %% import sqlite3 import pandas as pd import dtale import unicodedata from simple_query_test_pandas import ricercaforme, ricercalemmi, ricercaformelemmi, ricercalemmiforme, interpreter from test_occorrenzario_pandas import findtexts, findcontexts, findbib, contestimultipli, get_tables_occ #funzione di definizione sottocorpus def definiscisottocorpus (path, table, conditions=None): conn = sqlite3.connect(f"file:{path}/bibliografia/BiblioTLIO.db?mode=ro", uri=True) c = conn.cursor() query = "SELECT sigla FROM {} WHERE 1".format(table) if conditions: for key, value in conditions.items(): if isinstance(value, list): query += " AND {} = '{}'".format(key, "' OR '".join([str(v) for v in value])) print(query) else: query += " AND {}='{}'".format(key, value) c.execute(query) results = c.fetchall() conn.close() sottocorpus = [result[0] for result in results] return sottocorpus # %% path = "/Users/leonardocanova/Library/CloudStorage/OneDrive-ConsiglioNazionaledelleRicerche/TIGRO/Ricerche/db/first_db" siglas = definiscisottocorpus(path,"datibib", {"IQ": "TS", "[Titolo Abbreviato]": ["Albertano volg., 1275 (fior.)", "Simintendi, a. 1333 (prat.)"]}) print(siglas) # %%