· 8 years ago · Dec 21, 2017, 12:20 PM
1col names: ['Last Name', 'First Name', 'Job', 'Country']
2table_name = 'stud_data'
3query = "CREATE TABLE IF NOT EXISTS"+table_name+"("+"VARCHAR(250),".join
4(col) + "Varchar(250))"
5print("Query is:" ,query)
6cursor.execute(query)
7conn.commit()
8
9mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Name VARCHAR(250),First Name VARCHAR(250),Job VARCHAR(250),Country VARCHAR(250))' at line 1
10
11Query is: CREATE TABLE IF NOT EXISTS stud_data (Last Name VARCHAR(250),First Name VARCHAR(250),Job VARCHAR(250),Country VARCHAR(250))