From d680d0ed026c9578fefd4abd371bb75a1bfd0784 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Wed, 29 Oct 2008 21:10:42 +0000 Subject: [PATCH] bzr-revno: 55 --- openlp/database/BibleImpl.py | 116 ------------------ .../database/test/bibleverses_niv_short.csv | 70 +++++------ 2 files changed, 35 insertions(+), 151 deletions(-) delete mode 100644 openlp/database/BibleImpl.py diff --git a/openlp/database/BibleImpl.py b/openlp/database/BibleImpl.py deleted file mode 100644 index 0f21f4e5b..000000000 --- a/openlp/database/BibleImpl.py +++ /dev/null @@ -1,116 +0,0 @@ -from sqlalchemy import * -from sqlalchemy.sql import select - -import time -import datetime -import logging -import string - -import os, os.path -import sys -mypath=os.path.split(os.path.abspath(__file__))[0] -sys.path.insert(0,(os.path.join(mypath, '..', '..'))) - -from openlp.utils import ConfigHelper - -logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s') - -metadata = MetaData() -#Define the tables and indexes - -meta = Table('meta', metadata, - Column('key', String(255), primary_key=True), - Column('value', String(255)), -) - -testament = Table('Testament', metadata, - Column('id', Integer, primary_key=True), - Column('name', String(30)), -) - -books = Table('Books', metadata, - Column('id', Integer, primary_key=True), - Column('testament_id', None , ForeignKey('Testament.id')), - Column('name', String(30)), - Column('abbrev', String(30)), -) -Index('idx_name', books.c.name, books.c.id) -Index('idx_abbrev', books.c.abbrev, books.c.id) - -verses = Table('Verses', metadata, - Column('id', Integer, primary_key=True), - Column('book_id', None, ForeignKey('Books.id')), - Column('chapter', Integer), - Column('verse', Integer), - Column('text', Text), -) -Index('idx_chapter_verse_book', verses.c.chapter, verses.c.verse, verses.c.book_id, verses.c.id) - -class BibleDBImpl: - def __init__(self, biblename): - # Connect to database - path = ConfigHelper.getBiblePath() - #print path - self.biblefile = os.path.join(path, biblename+".bible") - #print self.biblefile - self.db = create_engine("sqlite:///"+self.biblefile) - self.db.echo = False - metadata.bind = self.db - metadata.bind.echo = False - - def createTables(self): - if os.path.exists(self.biblefile): # delete bible file and set it up again - os.remove(self.biblefile) - meta.create() - testament.create() - books.create() - verses.create() - - def loadData(self, booksfile, versesfile): - - metai =meta.insert() - metai.execute(key="dbversion", value="1") - metai.execute(key="version", value="Bible Version") - metai.execute(key="Copyright", value="(c) Some Bible company") - metai.execute(key="Permission", value="You have some") - print meta.select() - - #Populate the Tables - insi = testament.insert() - insi.execute(name="Old Testament") - insi.execute(name="New Testament") - print testament.select() - - fbooks=open(booksfile, 'r') - fverse=open(versesfile, 'r') - - insb = books.insert() - for line in fbooks: - print line - p = line.split(",") - insb.execute(testament_id=int(p[1]), name=p[2], abbrev=p[3]) - - t = books.select() - print t - - book_ptr = "" - - insv = verses.insert() - #Books._connection.debug=True - for line in fverse: - print line - p = line.split(",", 3) # split into 3 units and leave the rest as a single field - if book_ptr != p[0]: - r = self.db.execute(books.select(books.c.name==p[0])).fetchone() - book_ptr = p[0] - - print p[3] - insv.execute(book_id=r[0], chapter=int(p[1]), verse=int(p[2]), text=p[3]) - - def Run_Tests(self): - print "test print" - b = self.db.execute(books.select(books.c.name=='"John"')).fetchone() - print b - v = self.db.execute(verses.select(verses.c.chapter==1 and verses.c.verse==1 and verses.c.book_id == b[0])).fetchone() - print v - diff --git a/openlp/database/test/bibleverses_niv_short.csv b/openlp/database/test/bibleverses_niv_short.csv index 94a0c3a0e..df1f5c436 100644 --- a/openlp/database/test/bibleverses_niv_short.csv +++ b/openlp/database/test/bibleverses_niv_short.csv @@ -1,35 +1,35 @@ -"Genesis",1,1,"In the beginning God created the heavens and the earth." -"Genesis",1,2,"Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters." -"Exodus",1,1,"These are the names of the sons of Israel who went to Egypt with Jacob, each with his family:" -"Exodus",1,2,"Reuben, Simeon, Levi and Judah;" -"Exodus",2,1,"Now a man of the house of Levi married a Levite woman," -"Exodus",2,2,"and she became pregnant and gave birth to a son. When she saw that he was a fine child, she hid him for three months." -"Leviticus",1,1,"The Lord called to Moses and spoke to him from the Tent of Meeting. He said," -"Leviticus",1,2,"""Speak to the Israelites and say to them: 'When any of you brings an offering to the Lord, bring as your offering an animal from either the herd or the flock." -"Leviticus",1,3,"""'If the offering is a burnt offering from the herd, he is to offer a male without defect. He must present it at the entrance to the Tent of Meeting so that it will be acceptable to the Lord." -"Numbers",1,1,"The Lord spoke to Moses in the Tent of Meeting in the Desert of Sinai on the first day of the second month of the second year after the Israelites came out of Egypt. He said:" -"Numbers",1,2,"""Take a census of the whole Israelite community by their clans and families, listing every man by name, one by one." -"Matthew",1,1,"A record of the genealogy of Jesus Christ the son of David, the son of Abraham:" -"Matthew",1,2,"Abraham was the father of Isaac," -"Matthew",1,3,"Judah the father of Perez and Zerah, whose mother was Tamar," -"Matthew",1,4,"Ram the father of Amminadab," -"Matthew",1,5,"Salmon the father of Boaz, whose mother was Rahab," -"Matthew",1,6,"and Jesse the father of King David." -"Matthew",1,7,"Solomon the father of Rehoboam," -"Matthew",1,8,"Asa the father of Jehoshaphat," -"Matthew",2,1,"After Jesus was born in Bethlehem in Judea, during the time of King Herod, Magi from the east came to Jerusalem" -"Matthew",2,2,"and asked, ""Where is the one who has been born king of the Jews? We saw his star in the east and have come to worship "Matthew",3,1,"In those days John the Baptist came, preaching in the Desert of Judea" -"Matthew",3,2,"and saying, ""Repent, for the kingdom of heaven is near.""" -"Matthew",3,3,"This is he who was spoken of through the prophet Isaiah: ""A voice of one calling in the desert, 'Prepare the way for the Lord, make straight paths for him.'""" -"Mark",1,1,"The beginning of the gospel about Jesus Christ, the Son of God." -"Mark",1,2,"It is written in Isaiah the prophet: ""I will send my messenger ahead of you, who will prepare your way""--" -"Mark",1,3,"""a voice of one calling in the desert, 'Prepare the way for the Lord, make straight paths for him.'""" -"Luke",1,1,"Many have undertaken to draw up an account of the things that have been fulfilled among us," -"Luke",1,2,"just as they were handed down to us by those who from the first were eyewitnesses and servants of the word." -"Luke",1,3,"Therefore, since I myself have carefully investigated everything from the beginning, it seemed good also to me to write an orderly account for you, most excellent Theophilus," -"John",1,1,"In the beginning was the Word, and the Word was with God, and the Word was God." -"John",1,2,"He was with God in the beginning." -"John",1,3,"Through him all things were made; without him nothing was made that has been made." -"John",2,1,"On the third day a wedding took place at Cana in Galilee. Jesus' mother was there," -"John",2,2,"and Jesus and his disciples had also been invited to the wedding." -"John",2,3,"When the wine was gone, Jesus' mother said to him, ""They have no more wine.""" +"Genesis",1,1,"In the beginning God created the heavens and the earth." +"Genesis",1,2,"Now the earth was formless and empty, darkness was over the surface of the deep, and the Spirit of God was hovering over the waters." +"Exodus",1,1,"These are the names of the sons of Israel who went to Egypt with Jacob, each with his family:" +"Exodus",1,2,"Reuben, Simeon, Levi and Judah;" +"Exodus",2,1,"Now a man of the house of Levi married a Levite woman," +"Exodus",2,2,"and she became pregnant and gave birth to a son. When she saw that he was a fine child, she hid him for three months." +"Leviticus",1,1,"The Lord called to Moses and spoke to him from the Tent of Meeting. He said," +"Leviticus",1,2,"""Speak to the Israelites and say to them: 'When any of you brings an offering to the Lord, bring as your offering an animal from either the herd or the flock." +"Leviticus",1,3,"""'If the offering is a burnt offering from the herd, he is to offer a male without defect. He must present it at the entrance to the Tent of Meeting so that it will be acceptable to the Lord." +"Numbers",1,1,"The Lord spoke to Moses in the Tent of Meeting in the Desert of Sinai on the first day of the second month of the second year after the Israelites came out of Egypt. He said:" +"Numbers",1,2,"""Take a census of the whole Israelite community by their clans and families, listing every man by name, one by one." +"Matthew",1,1,"A record of the genealogy of Jesus Christ the son of David, the son of Abraham:" +"Matthew",1,2,"Abraham was the father of Isaac," +"Matthew",1,3,"Judah the father of Perez and Zerah, whose mother was Tamar," +"Matthew",1,4,"Ram the father of Amminadab," +"Matthew",1,5,"Salmon the father of Boaz, whose mother was Rahab," +"Matthew",1,6,"and Jesse the father of King David." +"Matthew",1,7,"Solomon the father of Rehoboam," +"Matthew",1,8,"Asa the father of Jehoshaphat," +"Matthew",2,1,"After Jesus was born in Bethlehem in Judea, during the time of King Herod, Magi from the east came to Jerusalem" +"Matthew",2,2,"and asked, ""Where is the one who has been born king of the Jews? We saw his star in the east and have come to worship "Matthew",3,1,"In those days John the Baptist came, preaching in the Desert of Judea" +"Matthew",3,2,"and saying, ""Repent, for the kingdom of heaven is near.""" +"Matthew",3,3,"This is he who was spoken of through the prophet Isaiah: ""A voice of one calling in the desert, 'Prepare the way for the Lord, make straight paths for him.'""" +"Mark",1,1,"The beginning of the gospel about Jesus Christ, the Son of God." +"Mark",1,2,"It is written in Isaiah the prophet: ""I will send my messenger ahead of you, who will prepare your way""--" +"Mark",1,3,"""a voice of one calling in the desert, 'Prepare the way for the Lord, make straight paths for him.'""" +"Luke",1,1,"Many have undertaken to draw up an account of the things that have been fulfilled among us," +"Luke",1,2,"just as they were handed down to us by those who from the first were eyewitnesses and servants of the word." +"Luke",1,3,"Therefore, since I myself have carefully investigated everything from the beginning, it seemed good also to me to write an orderly account for you, most excellent Theophilus," +"John",1,1,"In the beginning was the Word, and the Word was with God, and the Word was God." +"John",1,2,"He was with God in the beginning." +"John",1,3,"Through him all things were made; without him nothing was made that has been made." +"John",2,1,"On the third day a wedding took place at Cana in Galilee. Jesus' mother was there," +"John",2,2,"and Jesus and his disciples had also been invited to the wedding." +"John",2,3,"When the wine was gone, Jesus' mother said to him, ""They have no more wine."""