db

class openlp.plugins.bibles.lib.db.AlternativeBookNamesDB[source]

Bases: PyQt5.QtCore.QObject, openlp.core.lib.db.Manager

This class represents a database-bound alternative book names system.

conn = None
static create_alternative_book_name(name, book_reference_id, language_id)[source]

Add an alternative book name to the database.

Parameters:
  • name – The name of the alternative book name.
  • book_reference_id – The book_reference_id of the book.
  • language_id – The language to which the alternative book name belong.
cursor = None
static get_book_reference_id(name, language_id=None)[source]

Return a book_reference_id if the name matches.

Parameters:
  • name – The name to search the id.
  • language_id – The language_id for which language should be searched
static get_cursor()[source]

Return the cursor object. Instantiate one if it doesn’t exist yet. If necessary loads up the database and creates the tables if the database doesn’t exist.

static run_sql(query, parameters=(), commit=None)[source]

Run an SQL query on the database, returning the results.

Parameters:
  • query – The actual SQL query to run.
  • parameters – Any variable parameters to add to the query
  • commit – If a commit statement is necessary this should be True.
class openlp.plugins.bibles.lib.db.BibleDB(parent, **kwargs)[source]

Bases: openlp.core.lib.db.Manager

This class represents a database-bound Bible. It is used as a base class for all the custom importers, so that the can implement their own import methods, but benefit from the database methods in here via inheritance, rather than depending on yet another object.

create_book(name, bk_ref_id, testament=1)[source]

Add a book to the database.

Parameters:
  • name – The name of the book.
  • bk_ref_id – The book_reference_id from bibles_resources.sqlite of the book.
  • testamentDefaults to 1. The testament_reference_id from bibles_resources.sqlite of the testament this book belongs to.
create_chapter(book_id, chapter, text_list)[source]

Add a chapter and its verses to a book.

Parameters:
  • book_id – The id of the book being appended.
  • chapter – The chapter number.
  • text_list – A dict of the verses to be inserted. The key is the verse number, and the value is the verse text.
create_verse(book_id, chapter, verse, text)[source]

Add a single verse to a chapter.

Parameters:
  • book_id – The id of the book being appended.
  • chapter – The chapter number.
  • verse – The verse number.
  • text – The verse text.
delete_book(db_book)[source]

Delete a book from the database.

Parameters:db_book – The book object.
dump_bible()[source]

Utility debugging method to dump the contents of a bible.

get_book(book)[source]

Return a book object from the database.

Parameters:book – The name of the book to return.
get_book_by_book_ref_id(ref_id)[source]

Return a book object from the database.

Parameters:ref_id – The reference id of the book to return.
get_book_ref_id_by_localised_name(book, language_selection)[source]

Return the id of a named book.

Parameters:
  • book – The name of the book, according to the selected language.
  • language_selection – The language selection the user has chosen in the settings section of the Bible.
get_books()[source]

A wrapper so both local and web bibles have a get_books() method that manager can call. Used in the media manager advanced search tab.

get_chapter_count(book)[source]

Return the number of chapters in a book.

Parameters:book – The book object to get the chapter count for.
get_name()[source]

Returns the version name of the Bible.

get_verse_count(book_ref_id, chapter)[source]

Return the number of verses in a chapter.

Parameters:
  • book_ref_id – The book reference id.
  • chapter – The chapter to get the verse count for.
get_verses(reference_list, show_error=True)[source]

This is probably the most used function. It retrieves the list of verses based on the user’s query.

Parameters:
  • reference_list

    This is the list of references the media manager item wants. It is a list of tuples, with the following format:

    (book_reference_id, chapter, start_verse, end_verse)
    

    Therefore, when you are looking for multiple items, simply break them up into references like this, bundle them into a list. This function then runs through the list, and returns an amalgamated list of Verse objects. For example:

    [('35', 1, 1, 1), ('35', 2, 2, 3)]
    
  • show_error
save_meta(key, value)[source]

Utility method to save or update BibleMeta objects in a Bible database.

Parameters:
  • key – The key for this instance.
  • value – The value for this instance.
update_book(book)[source]

Update a book in the database.

Parameters:book – The book object

Search for verses containing text text.

Parameters:text – The text to search for. If the text contains commas, it will be split apart and OR’d on the list of values. If the text just contains spaces, it will split apart and AND’d on the list of values.
class openlp.plugins.bibles.lib.db.BibleMeta[source]

Bases: openlp.core.lib.db.BaseModel

Bible Meta Data

class openlp.plugins.bibles.lib.db.BiblesResourcesDB[source]

Bases: PyQt5.QtCore.QObject, openlp.core.lib.db.Manager

This class represents the database-bound Bible Resources. It provide some resources which are used in the Bibles plugin. A wrapper class around a small SQLite database which contains the download resources, a biblelist from the different download resources, the books, chapter counts and verse counts for the web download Bibles, a language reference, the testament reference and some alternative book names. This class contains a singleton “cursor” so that only one connection to the SQLite database is ever used.

cursor = None
static get_alternative_book_name(name, language_id=None)[source]

Return a book_reference_id if the name matches.

Parameters:
  • name – The name to search the id.
  • language_id – The language_id for which language should be searched
static get_book(name, lower=False)[source]

Return a book by name or abbreviation.

Parameters:
  • name – The name or abbreviation of the book.
  • lower – True if the comparison should be only lowercase
static get_book_by_id(book_id)[source]

Return a book by id.

Parameters:book_id – The id of the book.
static get_books()[source]

Return a list of all the books of the Bible.

static get_books_like(string)[source]

Return the books which include string.

Parameters:string – The string to search for in the book names or abbreviations.
static get_chapter(book_ref_id, chapter)[source]

Return the chapter details for a specific chapter of a book.

Parameters:
  • book_ref_id – The id of a book.
  • chapter – The chapter number.
static get_chapter_count(book_ref_id)[source]

Return the number of chapters in a book.

Parameters:book_ref_id – The id of the book.
static get_cursor()[source]

Return the cursor object. Instantiate one if it doesn’t exist yet.

static get_download_source(source)[source]

Return a download_source_id by source.

Parameters:source – The name or abbreviation of the book.
static get_testament_reference()[source]

Return a list of all testaments and their id of the Bible.

static get_verse_count(book_ref_id, chapter)[source]

Return the number of verses in a chapter.

Parameters:
  • book_ref_id – The id of the book.
  • chapter – The number of the chapter.
static get_webbible(abbreviation, source)[source]

Return the bibles a web_bible provide for download.

Parameters:
  • abbreviation – The abbreviation of the web_bible.
  • source – The source of the web_bible.
static get_webbibles(source)[source]

Return the bibles a web_bible provide for download.

Parameters:source – The source of the web_bible.
static run_sql(query, parameters=())[source]

Run an SQL query on the database, returning the results.

query
The actual SQL query to run.
parameters
Any variable parameters to add to the query.
class openlp.plugins.bibles.lib.db.Book[source]

Bases: openlp.core.lib.db.BaseModel

Bible Book model

get_name(language_selection=0)[source]
class openlp.plugins.bibles.lib.db.Verse[source]

Bases: openlp.core.lib.db.BaseModel

Topic model

openlp.plugins.bibles.lib.db.init_schema(url)[source]

Setup a bible database connection and initialise the database schema.

Parameters:url – The database to setup.