db¶
The db
module provides the database and schema that is the backend for
the Songs plugin
-
class
openlp.plugins.songs.lib.db.
Author
[source]¶ Bases:
openlp.core.lib.db.BaseModel
Author model
-
class
openlp.plugins.songs.lib.db.
AuthorSong
[source]¶ Bases:
openlp.core.lib.db.BaseModel
Relationship between Authors and Songs (many to many). Need to define this relationship table explicit to get access to the Association Object (author_type). http://docs.sqlalchemy.org/en/latest/orm/relationships.html#association-object
-
class
openlp.plugins.songs.lib.db.
AuthorType
[source]¶ Bases:
object
Enumeration for Author types. They are defined by OpenLyrics: http://openlyrics.info/dataformat.html#authors
The ‘words+music’ type is not an official type, but is provided for convenience.
-
Music
= 'music'¶
-
NoType
= ''¶
-
SortedTypes
= ['', 'words', 'music', 'words+music', 'translation']¶
-
TranslatedTypes
= ['', 'Words', 'Music', 'Words and Music', 'Translation']¶
-
Translation
= 'translation'¶
-
Types
= {'': '', 'music': 'Music', 'translation': 'Translation', 'words': 'Words', 'words+music': 'Words and Music'}¶
-
Words
= 'words'¶
-
WordsAndMusic
= 'words+music'¶
-
-
class
openlp.plugins.songs.lib.db.
Book
[source]¶ Bases:
openlp.core.lib.db.BaseModel
Book model
-
class
openlp.plugins.songs.lib.db.
MediaFile
[source]¶ Bases:
openlp.core.lib.db.BaseModel
MediaFile model
-
class
openlp.plugins.songs.lib.db.
Song
[source]¶ Bases:
openlp.core.lib.db.BaseModel
Song model
Add an author to the song if it not yet exists
Parameters: - author – Author object
- author_type – AuthorType constant or None
-
add_songbook_entry
(songbook, entry)[source]¶ Add a Songbook Entry to the song if it not yet exists
Parameters: - songbook_name – Name of the Songbook.
- entry – Entry in the Songbook (usually a number)
-
init_on_load
()[source]¶ Precompute a natural sorting, locale aware sorting key.
Song sorting is performance sensitive operation. To get maximum speed lets precompute the sorting key.
Remove an existing author from the song
Parameters: - author – Author object
- author_type – AuthorType constant or None
-
class
openlp.plugins.songs.lib.db.
SongBookEntry
[source]¶ Bases:
openlp.core.lib.db.BaseModel
SongBookEntry model
-
class
openlp.plugins.songs.lib.db.
Topic
[source]¶ Bases:
openlp.core.lib.db.BaseModel
Topic model
-
openlp.plugins.songs.lib.db.
init_schema
(url)[source]¶ Setup the songs database connection and initialise the database schema.
Parameters: url – The database to setup The song database contains the following tables:
- authors
- authors_songs
- media_files
- media_files_songs
- song_books
- songs
- songs_songbooks
- songs_topics
- topics
- authors Table
This table holds the names of all the authors. It has the following columns:
- id
- first_name
- last_name
- display_name
- authors_songs Table
This is a bridging table between the authors and songs tables, which serves to create a many-to-many relationship between the two tables. It has the following columns:
- author_id
- song_id
- author_type
- media_files Table
- id
- file_name
- type
- song_books Table
The song_books table holds a list of books that a congregation gets their songs from, or old hymnals now no longer used. This table has the following columns:
- id
- name
- publisher
- songs Table
This table contains the songs, and each song has a list of attributes. The songs table has the following columns:
- id
- title
- alternate_title
- lyrics
- verse_order
- copyright
- comments
- ccli_number
- theme_name
- search_title
- search_lyrics
- songs_songsbooks Table
This is a mapping table between the songs and the song_books tables. It has the following columns:
- songbook_id
- song_id
- entry # The song number, like 120 or 550A
- songs_topics Table
This is a bridging table between the songs and topics tables, which serves to create a many-to-many relationship between the two tables. It has the following columns:
- song_id
- topic_id
- topics Table
The topics table holds a selection of topics that songs can cover. This is useful when a worship leader wants to select songs with a certain theme. This table has the following columns:
- id
- name