/+junk/Dataanalys

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/Dataanalys

« back to all changes in this revision

Viewing changes to sqlCmd.py

  • Committer: Gustav Hartvigsson
  • Date: 2010-12-22 18:59:19 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20101222185919-xa4ot5ytlbiepf4w
Added a camand line interface, and finished up the awnser sheet thingy...

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
        conn = sqlite3.connect("./awnsers.sqlite")
15
15
        db = conn.cursor()
16
16
 
17
 
        startQueryShow = "select * from awnsers where("
 
17
        startQueryShow = "select * from test1 where("
18
18
        startQueryCount = "select count(*) from awnsers where("
19
19
        endQuery =");"
20
20
 
23
23
                """ Shows the query where
24
24
                IE: select * from <table> where <Command>
25
25
                example:
26
 
                        show test2 = 1 and test = 1"""
 
26
                show test2 = 1 and test = 1"""
27
27
                query = commandPromt.startQueryShow + line + commandPromt.endQuery
28
28
                try:
29
29
                        result = commandPromt.db.execute(query)
35
35
        
36
36
        def do_count(self,line):
37
37
                """ counts the query where
38
 
                IE: select count(*) from <table> where <Command>
39
 
                example:
40
 
                        count test2 = 1 and test = 1"""
 
38
        IE: select count(*) from <table> where <Command>
 
39
        example:
 
40
        count test2 = 1 and test = 1"""
41
41
                query = commandPromt.startQueryCount + line + commandPromt.endQuery
42
42
                try:
43
43
                        result = commandPromt.db.execute(query)
46
46
                else:
47
47
                        for row in result:
48
48
                                print(row[0])
49
 
        #TODO: Add a countAll command, it will show the numbor of each true value in the DB.
50
 
        #IE:
51
 
        #gud: 13
52
 
        #vegan: 4
53
 
        #etc etc.
 
49
        
54
50
 
55
51
        def do_exit(self,line):
56
52
                import awnsers_and_db_edit
57
 
                print("====== returning to main menu ======")##FIXME: why is this not printed before going into the main menu?
 
53
                print("====== returning to man menu ======")
58
54
                awnsers_and_db_edit.menu()
59
55
 
60
56
        def de_EOF(self, line):