/+junk/Dataanalys

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/Dataanalys
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
1
#!/usr/bin/env python3.1
1 by Gustav Hartvigsson
initial code commiinitial code committ
2
import sys
3
import sqlite3
4
5
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
6
#======================= connection to DB ===========================
7
8
conn = sqlite3.connect("./awnsers.sqlite") #makes the connection with the db file.
9
db = conn.cursor()
10
11
##create table from query from file: create table if not exists
12
13
f = open("./createDB.sql")
14
query = f.read()
15
db.execute(query)
16
f.close()
17
18
#===================== end DB connection ==========================
19
20
21
#===================== Futction section ===========================
22
1 by Gustav Hartvigsson
initial code commiinitial code committ
23
## menu
24
def menu():
25
	## menu options
26
	menuOptions="""1. show DB
27
2. edit DB
28
3. add to DB
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
29
4. exit
30
"""
1 by Gustav Hartvigsson
initial code commiinitial code committ
31
32
	print("select an option")
33
	print(menuOptions)
34
	menuOptionsInput = input(">>>>")
35
36
	#ifs and thens
4 by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet...
37
	if(menuOptionsInput == "1" or menuOptionsInput.lower() == "s" ):
1 by Gustav Hartvigsson
initial code commiinitial code committ
38
		dbShow()
39
		
4 by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet...
40
	elif(menuOptionsInput == "2" or menuOptionsInput.lower() =="e" ):
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
41
		dbEdit()
42
	
4 by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet...
43
	elif(menuOptionsInput == "3" or menuOptionsInput.lower() == "a" ):
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
44
		dbAdd()
45
	
4 by Gustav Hartvigsson
fixed som shit and started the initial work on the awnser sheet...
46
	elif(menuOptionsInput == "4" or menuOptionsInput.lower() == "q" ):
1 by Gustav Hartvigsson
initial code commiinitial code committ
47
		exit()
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
48
	
1 by Gustav Hartvigsson
initial code commiinitial code committ
49
	else:
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
50
		print("You need to select an option! in the list")
1 by Gustav Hartvigsson
initial code commiinitial code committ
51
		menu()
52
	
53
54
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
55
1 by Gustav Hartvigsson
initial code commiinitial code committ
56
57
#Show DB Function
58
def dbShow():
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
59
	print("DEBUG : Running dbShow()")
60
	#TODO: make it print counts of occurunsus of different true (integer 1) values
61
	
1 by Gustav Hartvigsson
initial code commiinitial code committ
62
	getQuery =""" select * from awnsers; """
63
	db.execute(getQuery)
64
	
65
	for row in db:
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
66
		print( row )
1 by Gustav Hartvigsson
initial code commiinitial code committ
67
	
68
	
69
	if(getQuery == None):
70
		print("No data in table.")
71
	
72
	menu()
73
3 by Gustav Hartvigsson
Made some changes and added the initial work on the different functions...
74
def dbEdit():
75
	print("DEBUG: running dbEdit()")
76
	#TODO: make it 
77
	menu()
78
79
80
def dbAdd():
81
	print("DEBUG: running dbAdd()")
82
	#TODO: make a function with all the questions and such.
83
	menu()
84
85
86
#==================== end function setion ==================
87
88
89
#==================== main call section ====================
1 by Gustav Hartvigsson
initial code commiinitial code committ
90
menu()
91