Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- conn.execute('''CREATE TABLE RESULTS(
- id INTEGER PRIMARY KEY AUTOINCREMENT,
- name TEXT NOT NULL,
- age TEXT NOT NULL,
- gender TEXT NOT NULL);''')
- #setting up the user input variables
- srcIn = input("what field do you want to search: id, name, age, or gender? ")
- srcQuery = input("what result do you want to find from the "+ srcIn + " search? ")
- if(srcIn == "age") or (srcIn == "id"):
- #by default input returns a string but it needs to be an int for age and id parameters
- srcQuery = int(srcQuery)
- print("converted to int")
- srcOut = input("what field do you want to return: id, name, age, or gender? ")
- print("making cursor")
- cursor = conn.execute("SELECT %s FROM RESULTS WHERE %s = %s" % (srcOut, srcIn, srcQuery))
- for row in cursor:
- print(srcOut + ": " + row[0])
- conn.close()
- print("closed database " + db)
- cursor = conn.execute("SELECT %s FROM RESULTS WHERE %s = %s" % (srcOut, srcIn, srcQuery))
- sqlite3.OperationalError: no such column: male
- srcOut = name
- srcIn = gender
- srcQuery = male
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement