diff options
Diffstat (limited to 'pyble.py')
-rw-r--r-- | pyble.py | 63 |
1 files changed, 0 insertions, 63 deletions
@@ -33,69 +33,6 @@ class Passage(Model): class CrossReference(Model): __fillable__ = ['passage_id1', 'passage_id2', 'relevance'] -def setup_tables(db): - schema = Schema(db) - - with schema.create('parts') as table: - table.string('name') - table.primary('name') - - with schema.create('books') as table: - table.string('canonical_name').primary() - - with schema.create('alternative_book_names') as table: - table.string('name').primary() - table.string('book') - table.foreign('book').references('canonical_name').on('books') - - with schema.create('verses') as table: - table.string('book') - table.small_integer('chapter') - table.small_integer('nr') - table.foreign('book').references('canonical_name').on('books') - table.primary(['book', 'chapter', 'nr']) - - with schema.create('translations') as table: - table.string('name').primary() - - with schema.create('translated_verses') as table: - table.string('translation') - table.string('book') - table.small_integer('chapter') - table.small_integer('nr') - table.string('text') - table.foreign('translation').references('name').on('translations') - table.foreign(['book', 'chapter', 'nr'])\ - .references(['book', 'chapter', 'nr']).on('verses')\ - .on_delete('restrict').on_update('cascade') - table.primary(['translation', 'book', 'chapter', 'nr']) - - with schema.create('passages') as table: - table.increments('id') - table.string('fst_book') - table.small_integer('fst_chapter') - table.small_integer('fst_nr') - table.string('snd_book') - table.small_integer('snd_chapter') - table.small_integer('snd_nr') - table.foreign(['fst_book', 'fst_chapter', 'fst_nr'])\ - .references(['book', 'chapter', 'nr']).on('verses')\ - .on_delete('restrict').on_update('cascade') - table.foreign(['snd_book', 'snd_chapter', 'snd_nr'])\ - .references(['book', 'chapter', 'nr']).on('verses')\ - .on_delete('restrict').on_update('cascade') - table.unique(['fst_book', 'fst_chapter', 'fst_nr', - 'snd_book', 'snd_chapter', 'snd_nr']) - - with schema.create('crossreferences') as table: - table.integer('passage_id1') - table.integer('passage_id2') - table.timestamps() - table.small_integer('relevance').default(0) - table.foreign('passage_id1').references('id').on('passages') - table.foreign('passage_id2').references('id').on('passages') - table.primary(['passage_id1', 'passage_id2']) - def setup_fill_alternative_book_names(db): with open('alternative_book_names.csv', 'r') as csvfile: reader = csv.reader(csvfile, delimiter=',', quotechar='"') |