libJournal v2.0.0

WARNING: This version of libJournal is BROKEN. Please refer to libJournal v2.1.0 which contains various fixes for problems within this version, along with some consistency fixes.

~~This version of libJournal is completely different from past versions, using all new behind the scenes libraries. Using this version is slightly more complicated, but becomes more effecient and has many new features to utilitze. To install this version, user this command:

pip install libJournal==2.0.0

Since we no longer use JSON to store all the journal entries, we must go about making the storage differently. In order to start using libJournal 2.0.0, you must set it up as below in order to use any other features:

# Import libJournal
from libjournal.libj import libJournal

# Initialize libJournal object
libj = libJournal()

# Create, format, and setup the database (called test.db in this instance)
libj.create_db("test")
libj.format_db("test.db")
libj.set_db_location("test.db")

The entry_new() method is used to add entries into the database, which records title, date, time, content, and number. The significance of number will be explained later:

# Adds an entry with the name "Dogs", and with the content "Cats"
libj.entry_new("Dogs", "Cats")

Unlike previous versions of libJournal, titles of entries can be the same!

In order to print/return all entries stored in certain databse, use the entries_all() method, and for the most recent entry the most_recent_entry() method can be used, examples of both are below:

# Returns all entries in the database
libj.entries_all()

# Returns the most recent entry in the databse
libj.most_recent_entry()

Due to the usage of SQLite3, more advanced search options are available, such as by title, date, and number. Number is an automatically assigned integer which is given to each entry upon creation, and can be used to specifically reference a single entry. Examples of all forms of searching are below:

# Searches all entries for titles named "Cats" (str). It will return a list of entries each assigned a number (in order of time) which can be used to read them.
libj.search_by_title("Cats")

# Searches all entries for the specific identifier number 4 (int) and tt will return a list of entries each assigned a number (in order of time) which can be used to read them.
libj.search_by_number(4)

# Searches all entries for the entries created on the date and it will return a list of entries each assigned a number (in order of time) which can be used to read them.
libj.search_by_date("2018-04-01")

In order to read the contents of entries, 3 commands exist each searching by one of the parameters listed above: title, number, date:

# Reads the second entry titled cats and will return it's contents
libj.search_by_title("Cats", 2)

# Reads the entry wit the identifier 4 and return it's contents
libj.search_by_number(4)

# Reads the third entry made on the date "2018-04-01" and returns it's contents
libj.search_by_date("2018-04-01", 3)

Finally, in order to delete an entry, you must delete it by it’s identifier number using the delete_by_number() method:

# Deletes the entry with the identifier number 4
libj.delete_entry(4)

And this is all that is included in libJournal 2.0.0! Check the library roadmap to see upcoming features and fixes. Downloads:

~~