-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.py
More file actions
35 lines (30 loc) · 793 Bytes
/
input.py
File metadata and controls
35 lines (30 loc) · 793 Bytes
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
28
29
30
31
32
33
import sqlite3
import re
conn = sqlite3.connect('customer.db')
cur = conn.cursor()
first_name = input("enter your first name ")
while not re.match("[A-Za-z]+", first_name):
print("Only letters are allowed")
first_name = input("enter your first name ")
last_name = input("enter your last name ")
while not re.match("[A-Za-z]+", last_name):
print("Only letters are allowed")
last_name = input("enter your last name ")
email = input ("enter your email name ")
while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", email):
print("invalid email")
email = input("enter your email ")
cur.execute(f"""
INSERT INTO customer (
first_name,
last_name,
email
)
VALUES (
'{first_name}',
'{last_name}',
'{email}'
)
""")
conn.commit()
conn.close()