# %% import sqlite3 # %% def getCursor(path="../db/test1.db"): con = sqlite3.connect("file:"+path+"?mode=ro", uri=True) cur = con.cursor() return cur def closeConn(cur): cur.connection.close() def doQuery(cur, queryText): queryReponse = cur.execute(queryText) results = queryReponse.fetchall() return results # %% cur1 = getCursor() # %% res1 = doQuery(cur1, "select cod, spec, norm from form where norm='gatto'") print(res1) # %% listOcc = ["occ00001", "occ00002", "occ00003"] res2 = [] for table in listOcc: res2 = res2 + doQuery(cur1, "select ntx, pitxt from " + table + " where cod=" + str(res1[0][0])) print(res2) # %% with open("../db/itxt/p07", 'r', encoding="utf-32-le") as f: f.seek(4*int(res2[0][1]), 0) char = f.read(20) print(char) # %% # Experimentally: 'Gatto' (exact spelling) is in 'p07' with open("../db/itxt/p07", 'r', encoding="utf-32-le") as file: pyppa = file.read() print( pyppa[int(res2[0][1])-20:int(res2[0][1])+20] ) print() print( pyppa[int(res2[1][1])-20:int(res2[1][1])+20] ) # %%