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
|
#!/usr/bin/env python3.1
"""
This file contains the plotting funcioton that plots the data into a bar graph.
"""
import sys
import sqlite3
import numpy
class plotDB(object):
def __init__(self):
##This array is passed to getDB
self.nameArray = ["gudar", "spoken", "religos", "sekulart" ,"vegan" ,"mars" ,"globaluppvarmning" ,"manen" ,"motion" ,"sund" ,"deprimerad_host" ,"sno" ,"oppet" ,"dodsstraff" ,"kvinnors_rattigheter" ,"abort", "kvinnors_kropp", "deprimerad_var" ,"gast_sverige" ,"fodd_sverige" ,"foraldrar_sverige" ,"komentarer"]
GetData = getDB(self.nameArray)
def doPlot(self):
CountArray = GetData.doGet()
class getDB(object):
""" returns an array of counts of from the database"""
def __init__(self, iarray):
self.conn = sqlite3.connect("./awnsers.sqlite")
self.db = self.conn.cursor()
self.nameArray = iarray
self.countArray = list()
self.countStart = "select count(*) from awnsers where("
self.countEnd = " == 1);"
def doGet(self):
for name in self.nameArray:
getItem = self.db.execute(self.countStart + str(name) + self.countEnd )
for item in getItem:
self.countArray.append(item)
return self.countArray
|