Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ppf.jabref

pypi downloads/month

ppf.jabref provides a python interface to JabRef SQL databases. It maps database relations to python classes using SQLAlchemy. Also, ppf.jabref provides tools to parse the data stored inside the database tables.

JabRef's Database Layout

A JabRef database has these tables:

tables in JabRef DB

  • ENTRY holds an ID, the entry type (e.g. 'book', or 'article'), and a version number
  • FIELD uses the same entry as a foreign key, and lists all the fields in the entries row by row as key-value pairs.
  • METADATA holds data about your library such as the base path of your document folder and the definitions of your filter groups.

The "file" field is a text describing which files are linked the the present entry. Note that all linked files are listed in a single row in the DB. The links are separated by ';' inside the text. Also, each link has multiple properties: name, path, and filetype. In the following example, entry_shared_id 2 has a single link with name='', path='a.pdf', filetype='PDF'.

Excerpt from ENTRY table Excerpt from FIELD table

Using ppf.jabref

ppf.jabref relies on SQLAlchemy for database access. All that ppf.jabref adds to this is a data model which makes sqlalchemy understand how a JabRef database is structured (by providing classes Entry and Field).

A simple example that queries all entries and prints a selection of the fields looks like this:

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from ppf.jabref import Entry, File

engine = create_engine('<your connection string here>', echo=False)
Session = sessionmaker(bind=engine)
session = Session()

q = session.query(Entry)
for entry in q:
    print(entry.fields['author'], '\t',
        entry.fields['title'], '\t',
        entry.fields['year'], '\t', end='')

    files = File.from_string(entry.fields['file'])
    for i in range(len(files)):
        f = files[i]
        print(f.path, '\t', end='')

The first 6 lines are setup code to import required packages and to set up the database connection. The query then uses ppf.jabref's Entry class to obtain all Entries (=references) in the JabRef database. The for-loop shows how to access fields and uses the File class to find out where the documents linked to this entry are stored.

Installation

ppf.jabref is available via pypi:

pip install ppf.jabref

Still reading?

If you read this far, you're probably not here for the first time. If you use and like this project, would you consider giving it a Github Star? (The button is at the top of this website.) If not, maybe you're interested in one of my other projects?

Contributing

Did you find a bug and would like to report it? Or maybe you've fixed it already or want to help fixing it? That's great! Please read CONTRIBUTING to learn how to proceed.

To help ascertain that contributing to this project is a pleasant experience, we have established a code of conduct. You can expect everyone to adhere to it, just make sure you do as well.

Change Log

  • 0.1.2: Fix problem with versioning
  • 0.1.1: Fix sqlalchemy deprecation warning, docstrings
  • 0.1.0: Initial release

About

Python interface to JabRef SQL-database.

Topics

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages