I need assistance with creating an automatic ID for the Employee's when the other information is inputted by the user, is anyone able to help? I don't want the Employee ID to be asked to be inputted by the user, I would like it to be automatically generated and inputted into that field. I also have to program it in python, I can't use a SQL program or anything. Feel free to change any parts of the code, it's pretty flimsy at the moment, I've been messing around with the 'rowid' code for a bit trying to get that to work and I can't figure it out, many thanks.
import sqlite3
def AddEmployee():
FirstName = input("Plaese enter the
employee's First Name: ")
LastName = input("Please enter the
employee's Last Name: ")
DName = input("Please Enter the employee's
Department Area: ")
Gender = input("Please enter the employee's
Gender: ")
Phone = int(input("Please enter the
employee's phone number: "))
Address1 = input("Please Enter the
employee's Address1: ")
Town = input("Please Enter the employee's
Town: ")
Postcode = input("Please Enter the
employee's Postcode: ")
DOB = input("Please Enter the employee's
Date of Birth: ")
HireDate = input("Please Enter the
employee's Date of Employment: ")
db = sqlite3.connect("Database.db")
cursor = db.cursor()
cursor.execute("INSERT INTO Employees
VALUES(rowid, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
(EmployeeID, FirstName, LastName, DName,
Gender, Phone, Address1, Town, Postcode,
DOB, HireDate))
db.commit()
cursor.close()
db = sqlite3.connect("Database.db")
cursor = db.cursor()
cursor.execute("""CREATE TABLE IF NOT
EXISTS Employees
(EmployeeID integer PRIMARY KEY
AUTOINCREMENT, DName integer,
FirstName text, LastName text, Gender text,
Phone text,
Address1 text, Town text, Postcode text,
DOB Date,
HireDate Date)""")
cursor.execute("""CREATE TABLE IF NOT
EXISTS Salaries
(SalaryID integer PRIMARY KEY
AUTOINCREMENT, EmployeeID integer,
DepartmentDI integer, RegisterID integer,
FirstName text,
LastName text, Address1 text, Town text,
Postcode text, DOB Date,
HireDate Date, SalaryAmount integer,
DhourlyRate integer,
DOvertimeHourlyRate integer)""")
cursor.execute("""CREATE TABLE IF NOT
EXISTS Register
(RegisterID integer PRIMARY KEY
AUTOINCREMENT, EmployeeID integer,
Date Date, Time Time, Present Boolean,
HoursWorked integer,
OvertimeWorked integer)""")
cursor.execute("""CREATE TABLE IF NOT
EXISTS Departments
(DepartmentID integer PRIMARY KEY
AUTOINCREMENT, DName text, DQuota integer,
DHourlyRate integer, DovertimeHourlyRate
integer)""")
db.commit()
cursor.close()
AddEmployee()