I'm making a car number registration and I would like to transfer the car numbers to database. The car number correct format is ABC123 3 letters and 3 numbers. I just started data science, or how could I call the sql science. So the thing is that I don't know how to create the table with the CARNUM Data type. For example here's the code which I use to create an table.
create_table_query = '''CREATE TABLE Vartotojai
(ID INT PRIMARY KEY NOT NULL,
CARNUM TEXT NOT NULL,
TIME TIME); '''
cursor.execute(create_table_query)
connection.commit()
print("Table created successfully in PostgreSQL ")
In this CARNUM TEXT NOT NULL, I use Text, but I think this is not what I need to use for 3x Letters and 3x Numbers. Also do I need to use the NOT NULL? Cause I'm getting the numbers from user input so I use this as return for car numbers:
while True:
car_numb = input("Input car number:")
if car_numb_re.match(car_numb) and car_numb.isupper():
# matches!
print("Match")
Registration = True
TicketReg(car_numb)
break
elif car_numb.islower():
print("Wrong number format. Should be (XXX123)")
continue
Format in python for car numbers is something like this.
car_numb_re = re.compile(r'^[A-Z]{3}\d{3}$')