zoviz.database module

Class for handling zotero.sqlite database connection, queries, and visualization

class zoviz.database.Creator(name, creator_id)[source]

Bases: object

Content-creator data for use as a graph node

class zoviz.database.DB(db_path=None)[source]

Bases: object

Interface layer for zotero.sqlite database. Relies on the assumption that the entire database is small enough to load into memory without issue.

Tables are loaded from disk the first time they are accessed.

build_creator_graph(collection: str) → networkx.classes.multigraph.MultiGraph[source]

Build a graph data structure of collaborative work

Parameters:collection (str) – Zotero Collection name
Returns:MultiGraph with Creator objects as nodes and 1 edge per collaboration
Return type:nx.MultiGraph
close()[source]

Close database connection

load_table(name: str) → pandas.core.frame.DataFrame[source]

Load a whole table from disk

Parameters:name (str) – Name of table
Returns:Table contents
Return type:pd.DataFrame
query_df(query: str) → pandas.core.frame.DataFrame[source]

Return the result of a query as a DataFrame

Parameters:query (str) – String containing SQL query
Returns:DataFrame of result
Return type:pd.DataFrame
query_table_columns(name: str) → list[source]

Get list of column names for a table

Parameters:name (str) – Name of table
Returns:List of columns
Return type:list
zoviz.database.guess_db_path()[source]

Guess location of zotero.sqlite based on operating system

zoviz.database.validate_db_path(db_path: str)[source]

Check if the database file exists

Parameters:db_path (str) – Path to zotero.sqlite
Raises:FileNotFoundError – Raised if database does not exist