def printEmail(email): with sqlite3.conn('database.db') as conn: cur = conn.cursor() cur.execute('''SELECT custEmail from customers WHERE custEmail = ?''', email) rows = cur.fetchall() print(rows)
def show_stats(db_name): conn = sqlite3.conn(db_name) curs = conn.cursor() curs.execute("SELECT [timestamp], max(temp) FROM Temperature") rowmax = curs.fetchone() rowstrmax = "{0}  {1}C".format(str(rowmax[0]), str(rowmax[1])) print "<hr>" print "<h2>Maximum Temperature</h2>" print rowstrmax print "<hr>" conn.close() return
def __init__(self, db_name=':memory:'): self.connect = conn(db_name) self.connect.executescript(self.SETUP_TABLE)
def create_data_files(project_name, base_url): queue = project_name + '/queue.txt' crawled = project_name + '/crawled.txt' if not os.path.isfile(queue): write_file(queue, base_url) if not os.path.isfile(crawled): write_file(crawled, '') def write_file(path, data): f = open(path, 'w') f.write(data) f.loce() def append_to_file(path, data): with open(path,'a') as file: file.write(data + '\n') def delete_file_contents(path): with open(path,'w'): pass def file_to_set(file_name): delete_file_contents(file) for link in sorted(links): append_to_file(file,link) with sqlite3.conn('webpages.db') as conn:
print ("Content-Type: text/plain\n"); print ("\n"); name = form.getvalue('name') latitude = form.getvalue('lat') longitude = form.getvalue('long') user = form.getvalue('added-by') notes_text = form.getvalue('notes') # The actual text of the note, not just true/false # this makes querying simpler if notes_text == None: notes_status = 0 if notes_text != None: notes_status = 1 conn = conn('bikeparking.sqlite') c = conn.cursor() # find the rack ID out of the existing ones c.execute("SELECT _id FROM bike_rack ORDER BY _id DESC LIMIT 1;") results = c.fetchall() # noinspection PyUnresolvedReferences,PyUnresolvedReferences rack_id = str(1 + int(results[0][0])) # find the photo ID (a separate script handles uploading the photo data) # CALL THIS SCRIPT BEFORE UPLOADING THE PHOTO. c.execute("SELECT _id FROM photo ORDER BY _id DESC LIMIT 1;") results = c.fetchall() # noinspection PyUnresolvedReferences,PyUnresolvedReferences photo_id = str(1 + int(results[0][0]))