Now the database is made if necessary, not manually. Should be done a long time ago.
This commit is contained in:
parent
ff2f4e3407
commit
0d84d59ca2
18
egon.py
18
egon.py
|
@ -18,7 +18,7 @@ from pysqlite2 import dbapi2 as sqlite
|
||||||
from qrc_resources import *
|
from qrc_resources import *
|
||||||
|
|
||||||
|
|
||||||
__version__ = "1.0.0"
|
__version__ = "1.0.1"
|
||||||
|
|
||||||
|
|
||||||
main = None
|
main = None
|
||||||
|
@ -1520,12 +1520,15 @@ class BookModel():
|
||||||
## Connect to the database and return the cursor and connection
|
## Connect to the database and return the cursor and connection
|
||||||
def initDB():
|
def initDB():
|
||||||
conn = sqlite.connect('egon.db')
|
conn = sqlite.connect('egon.db')
|
||||||
curs = conn.cursor()
|
cursor = conn.cursor()
|
||||||
return curs, conn
|
|
||||||
|
|
||||||
## Initialize the tables
|
cursor.execute('''
|
||||||
def initNewDB():
|
SELECT name FROM sqlite_master
|
||||||
cursor, conn = initDB()
|
WHERE type='table'
|
||||||
|
ORDER BY name
|
||||||
|
''')
|
||||||
|
|
||||||
|
if cursor.fetchall() == []:
|
||||||
initSemesterDB(cursor)
|
initSemesterDB(cursor)
|
||||||
initAssignmentDB(cursor)
|
initAssignmentDB(cursor)
|
||||||
initReadingDB(cursor)
|
initReadingDB(cursor)
|
||||||
|
@ -1533,6 +1536,9 @@ def initNewDB():
|
||||||
initBookDB(cursor)
|
initBookDB(cursor)
|
||||||
initCourseDB(cursor)
|
initCourseDB(cursor)
|
||||||
initCourseUsesBook(cursor)
|
initCourseUsesBook(cursor)
|
||||||
|
|
||||||
|
return cursor, conn
|
||||||
|
|
||||||
exitDB(conn)
|
exitDB(conn)
|
||||||
|
|
||||||
# Create the database
|
# Create the database
|
||||||
|
|
Reference in New Issue