summaryrefslogtreecommitdiff
path: root/access_methods.py
blob: f315b82e6479c4193afbfaecbc962de365b82449 (plain)
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
from sqlite3 import *

def IIf(chk, true_case, false_case=None):
	if chk: return true_case
	else: return false_case

def Nz(val, nul_case=0):
	if val == None: return nul_case
	else: return val

# return a list of dictionaries from a db query
# need the connection. Is inherent in DAO.Database
# Read only
def OpenRecordset(con, qry_sql, param=None):
	cur = con.cursor()
	rst = []
	k = []
	
	if param != None: res = cur.execute(qry_sql, param)
	else: res = cur.execute(qry_sql)
	
	for desc in cur.description: k.append(desc[0])
	
	for row in res.fetchall(): rst.append(dict(zip(k,row)))
	
	cur = None
	return rst