· 8 years ago · Dec 10, 2017, 10:20 PM
1import sqlite3
2
3 connection = sqlite3.connect('shop.db')
4 cursor = connection.cursor()
5 create_table = '''
6 CREATE TABLE IF NOT EXISTS employee (
7 staff_ID INTEGER PRIMARY KEY,
8 password CHAR(4),
9 fname VARCHAR(20),
10 lname VARCHAR(30));'''
11 cursor.execute(create_table)
12
13 staffid = input('staff id: ')
14 password = input('password: ')
15 cursor.execute('SELECT * FROM employee WHERE staff_ID=? AND password=?', [staffid, password])
16 row = cursor.fetchone()
17 if row != None:
18 name = row[fname]+' '+row[lname]