JSON Files:
https://github.com/aruljohn/Bible-kjv
Python Script:
import json
import sqlite3
conn = sqlite3.connect('sword.db')
c = conn.cursor()
bookNames = ["Genesis", "Exodus", "Leviticus", "Numbers", "Deuteronomy", "Joshua", "Judges", "Ruth", "1Samuel", "2Samuel", "1Kings", "2Kings", "1Chronicles", "2Chronicles", "Ezra", "Nehemiah", "Esther", "Job", "Psalms", "Proverbs", "Ecclesiastes", "SongofSolomon", "Isaiah", "Jeremiah", "Lamentations", "Ezekiel", "Daniel", "Hosea", "Joel", "Amos", "Obadiah", "Jonah", "Micah", "Nahum", "Habakkuk", "Zephaniah", "Haggai", "Zechariah", "Malachi", "Matthew", "Mark", "Luke", "John", "Acts", "Romans", "1Corinthians", "2Corinthians", "Galatians", "Ephesians", "Philippians", "Colossians", "1Thessalonians", "2Thessalonians", "1Timothy", "2Timothy", "Titus", "Philemon", "Hebrews", "James", "1Peter", "2Peter", "1John", "2John", "3John", "Jude", "Revelation"]
count=0
B_KEY_BOOK_NAME = "book_name";
B_KEY_CHAP_NUM = "chapter_num";
B_KEY_VERSE_NUM = "verse_num";
B_KEY_VERSE_TEXT = "verse_text";
c.execute("CREATE TABLE " + "bible" + "("
+ B_KEY_BOOK_NAME + " TEXT, "
+ B_KEY_CHAP_NUM + " INTEGER, "
+ B_KEY_VERSE_NUM + " INTEGER, "
+ B_KEY_VERSE_TEXT + " TEXT" + ")")
C_KEY_ID = "id";
C_KEY_SEQ = "seq";
C_KEY_BOOK_NAME = "book_name";
C_KEY_CHAP_NUM = "chapter_num";
C_KEY_START_VERSE_NUM = "start_verse_num";
C_KEY_END_VERSE_NUM = "end_verse_num";
C_KEY_NEXT_DATE_OF_REVIEW = "next_date_of_review";
C_KEY_SPACE = "space";
C_KEY_SEC_ID = "sec_id";
c.execute("CREATE TABLE " + "chunk" + "("
+ C_KEY_ID + " INTEGER PRIMARY KEY, "
+ C_KEY_SEQ + " INTEGER, "
+ C_KEY_BOOK_NAME + " TEXT, "
+ C_KEY_CHAP_NUM + " INTEGER, "
+ C_KEY_START_VERSE_NUM + " INTEGER, "
+ C_KEY_END_VERSE_NUM + " INTEGER, "
+ C_KEY_NEXT_DATE_OF_REVIEW + " TEXT, "
+ C_KEY_SPACE + " INTEGER, "
+ C_KEY_SEC_ID + " INTEGER" + ")")
for i in range(66):
with open('JSON/' + bookNames[i] + '.json') as data_file:
data = json.load(data_file)
nChap = len(data["chapters"])
print(nChap)
for j in range(nChap):
nVerse = len(data["chapters"][j]["verses"])
for k in range(nVerse):
c.execute("INSERT INTO bible VALUES(" + "'" + data["book"] + "'" + "," + data["chapters"][j]["chapter"] + "," + str(k+1) + "," + "'" + data["chapters"][j]["verses"][k][str(k+1)] + "'" + ")")
print(bookNames[i] + " Done")
conn.commit()
conn.close()
Browse Database:
SQLiteOnline – https://sqliteonline.com/
Steps:
- Download all the 66 JSON files from the GitHub repository.
- Store these files in a folder named JSON, and store this JSON folder in another folder(say my project) where you want to put your python script.
- Now save the python script in the folder my project, and run it.
- Once done, you will find the file example.db in the my project folder.
- You can browse this database file by using the SQLiteOnline browser.
Leave a comment