pasobres.blogg.se

Bible quotes database
Bible quotes database




".On Saturday, July 28, 2012, three senior citizens broke into one of the most secure nuclear weapons facilities in the world. _addr ( book, chap, vers ), text )) return verses def _addr ( self, book, chap, vers ): """Construct a verse reference from the final three parameters.""" return ''. If the query matched any verses, the verse reference is deduced and used with the verse text to construct an array of Verse objects.""" if rows : verses = for vers, text in rows : verses.

bible quotes database

acquire () if ret : return ret raise ret def _verses ( self, book, chap, rows ): """Wrap the text from the rows in Verse objects. put (( lock, one, sql, parameters, ret )) lock. This prevents SQLite3 from throwing exceptions.""" lock, ret = _thread. The parameters for the query are dumped into a queue, and the answer is retrieved when it becomes available. This is a powerful shortcut method that is the closest connection other threads will have with the SQL server. _verses ( book, chap, rows ) def _fetch ( self, one, sql, * parameters ): """Execute the specified SQL query and return the results. _fetch ( False, '''select vers, text from verses where book=? and chap=? and vers>=? and vers<=? order by vers asc''', book, chap, vers_a, vers_b ) return self. _fetch ( True, '''select text from verses where book=? and chap=? and vers=?''', book, chap, vers ) if row is not None : return )] def fetch_range ( self, book, chap, vers_a, vers_b ): """Fetch all verses in the range and wrap in Verse objects.""" rows = self. _verses ( book, chap, rows ) def fetch_verse ( self, book, chap, vers ): """Fetch one verse as specified and wrap in a Verse object.""" row = self. _fetch ( False, '''select vers, text from verses where book=? and chap=? order by vers asc''', book, chap ) return self. release () def fetch_chapter ( self, book, chap ): """Fetch all verses from chapter and wrap in Verse objects.""" rows = self. execute ( sql, parameters ) data = cursor. Queue () while True : lock, one, sql, parameters, ret = self.

bible quotes database bible quotes database

If the connection was made successfully, then the server goes into a continuous loop, processing SQL queries.""" try : database = sqlite3. A SQLite3 connection is made in this thread with errors being raised again for the instantiator.

bible quotes database

_error def _serve ( self, * args ): """Run a server continuously to answer SQL queries. The verses returned from queries are automatically wrapped in their own Verse objects.""" # A copy of this can be found at library._VerseFile.BOOKS BOOKS = ( 'Genesis', 'Exodus', 'Leviticus', 'Numbers', 'Deuteronomy', 'Joshua', 'Judges', 'Ruth', '1 Samuel', '2 Samuel', '1 Kings', '2 Kings', '1 Chronicles', '2 Chronicles', 'Ezra', 'Nehemiah', 'Esther', 'Job', 'Psalm', 'Proverbs', 'Ecclesiastes', 'Song of Solomon', 'Isaiah', 'Jeremiah', 'Lamentations', 'Ezekiel', 'Daniel', 'Hosea', 'Joel', 'Amos', 'Obadiah', 'Jonah', 'Micah', 'Nahum', 'Habakkuk', 'Zephaniah', 'Haggai', 'Zechariah', 'Malachi', 'Matthew', 'Mark', 'Luke', 'John', 'Acts', 'Romans', '1 Corinthians', '2 Corinthians', 'Galatians', 'Ephesians', 'Philippians', 'Colossians', '1 Thessalonians', '2 Thessalonians', '1 Timothy', '2 Timothy', 'Titus', 'Philemon', 'Hebrews', 'James', '1 Peter', '2 Peter', '1 John', '2 John', '3 John', 'Jude', 'Revelation' ) def _init_ ( self, * args ): """Initialize the BibleServer with a SQLite3 database thread.""" self. Since a SQLite3 database can only accept queries on the thread that it was created on, this server receives requests through a queue and sends back the result through a list and mutex mechanism. Pulling Bible verses out of a database allows query details to be abstracted away and powerful Verse objects returned to the caller.""" # _author_ = 'Stephen "Zero" Chappell ' _date_ = '11 February 2010' _version_ = '$Revision: 3 $' # import _thread import sqlite3 import queue import verse # class BibleServer : """Execute a protected SQLite3 database on a singular thread. #! /usr/bin/env python """Serve verses from the Bible in response to SQL queries.






Bible quotes database