Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

model test of DB queries

  • Loading branch information...
commit 44ef5c11667638c15add35d37cbcfd396b24a460 1 parent 92bc5fa
@djmailhot djmailhot authored
Showing with 13 additions and 5 deletions.
  1. +3 −1 src/{test.py → model_test.py}
  2. +10 −4 src/query.py
View
4 src/test.py → src/model_test.py
@@ -1,5 +1,7 @@
from model import *
m = Model(dict())
-print str(m.c_query.generate_countries("mexico", 2))
+q = m.c_query.generate_countries("mexico", 2)
+print "RESULTS"
+print str(q)
#print str(m.q_query.generate_questions( ["mexico"] ))
View
14 src/query.py
@@ -29,7 +29,9 @@ def generate_questions(self,tags):
else:
cur.execute(get_question_by_tags(tags))
+ print "Query Questions"
for row in cur.fetchall():
+ print str(row)
#???? = row.split(",")
#extract values
text = None
@@ -39,7 +41,7 @@ def generate_questions(self,tags):
q_list.append(Question(text, answer, choices, q_id))
- self.db = sqlite.close()
+ db.close()
return q_list
@@ -64,14 +66,16 @@ def generate_countries(self, start_country, number):
"tags" - a tuple of tags for this country (including the country name)
'''
import sqlite3 as sqlite
- self.db = sqlite.connect(self.database_path)
- c = self.db.cursor()
+ db = sqlite.connect(self.database_path)
+ c = db.cursor()
id_set = set()
chosen_set = set()
+ print "Query Countries"
c.execute( query_countries() )
for row in c.fetchall():
+ print str(row)
c_id, name = row.split(",")
if name == start_country:
chosen_set.add(c_id)
@@ -85,11 +89,13 @@ def generate_countries(self, start_country, number):
chosen_set = id_set
+ print "Query Country Info"
info_hash_list = list()
for c_id in chosen_set:
c.execute( get_tags(c_id) )
info_dict = dict()
for row in c.fetchall():
+ print str(row)
#??? = row.split(",")
#extract the info for this country
name = None
@@ -100,6 +106,6 @@ def generate_countries(self, start_country, number):
info_hash_list.append(info_dict)
- self.db = sqlite.close()
+ db.close()
return info_hash_list
Please sign in to comment.
Something went wrong with that request. Please try again.