0

I've search trought a lot a internet site and I cannot find the answer. I try to create 4 tables in my SQLite database with this code:

 try:
 conn = sqlite3.connect(os.path.join(current_directory, 'fidouda.db'))
 c = conn.cursor()
 c.execute('''CREATE TABLE Clients (ID INTEGER PRIMARY KEY AUTOINCREMENT, Prenom, Nom, Adresse, Email, Telephone, Genre, Factures, Fidelite);''')
 c.execute('''CREATE TABLE Factures (ID, Client, Items, Date, Prix, Promotion, Sous-total, Total, Payer, Rpayer);''')
 c.execute('''CREATE TABLE Inventaire (Stock, Nom, Prix);''')
 c.execute('''CREATE TABLE Rabais (Nom, Pourcentage);''')
 except Error as e:
 print(e)
 finally:
 if conn:
 conn.close()
 return os.path.join(current_directory, fname)

The problem is that only the first table are created. How can I create all my table ?

asked Sep 20, 2019 at 15:21
1
  • Are you getting an error message? Except for the first column in the first table, none of these columns have data types, which I thought was required. Commented Sep 20, 2019 at 15:25

1 Answer 1

2

If you run this code, it will output this error:

sqlite3.OperationalError: near "-": syntax error

Specifically, the hyphen in the column Sous-total, you can either surround the column name in quotes, like this:

c.execute('''CREATE TABLE Factures (ID, Client, Items, Date, Prix, Promotion, 'Sous-total', Total, Payer, Rpayer);''')

Or pick another column name that won't cause problems.

answered Sep 20, 2019 at 15:26
Sign up to request clarification or add additional context in comments.

1 Comment

That work ... I dont know why but when I run this, I dont get error ... Maybe "hidden" by other thing in my script. I feel a little bit dumb .... Thanks a lot

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.