Skip to content

Commit

Permalink
fix SQLite access to cite keys after better-bibtex upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
plandes committed Oct 25, 2023
1 parent e559f73 commit 896145b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/python/zensols/zotsite/betterbib.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ def data(self) -> Dict[str, Any]:
path = self.lib.data_dir / 'better-bibtex.sqlite'
logger.info(f'reading bibtex DB at {path}')
conn = sqlite3.connect(':memory:')
conn.execute('ATTACH DATABASE ? AS betterbibtex', (path,))
conn.execute('ATTACH DATABASE ? AS betterbibtex', (str(path),))
try:
return [ tuple(k) for k in conn.execute("""select * from betterbibtex.citationkey""") ]
rows = tuple(conn.execute("""select * from betterbibtex.`better-bibtex`"""))
assert len(rows) == 3
rows = tuple(filter(lambda r: r[0] == 'better-bibtex.citekey', rows))
assert len(rows) == 1
jstr = rows[0][1]
return json.loads(jstr)
finally:
conn.close()

Expand Down

0 comments on commit 896145b

Please sign in to comment.