-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabaseCreate.py
More file actions
42 lines (28 loc) · 965 Bytes
/
databaseCreate.py
File metadata and controls
42 lines (28 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#The creation of the game database
import sqlite3
import databaseVersion
def createDatabase(sqliteFile):
'''The creation of the database'''
try:
#connecting to the database
conn = sqlite3.connect(sqliteFile)
c = conn.cursor()
print('Connected') #temp line
# c.executescript to create lots of tables at once
c.execute('''CREATE TABLE games (id_game_main INTEGER PRIMARY KEY, title TEXT, description TEXT)''')
print('created table games')
#database version identifier
c.execute('''CREATE TABLE databaseVersion (versionNumber INTEGER PRIMARY KEY)''')
print('created table databaseversion')
dbv = int(databaseVersion.versionCreate())
print(dbv)
#add preset values
c.execute('''INSERT INTO databaseVersion VALUES(?)''', (dbv)) # not working
print('inserted databaseVersion')
conn.commit()
return
except:
#Roll back if fails
conn.rollback()
print('\nFailed to create database')
return