I’m facing an issue in SQL query while creating a table in which I have the following columns:
Table Name : ideal
Columns:
id x y1 y2 y3 y4 —— y50
Basically I’m writing a python program in which I’m trying to make a table using SQL query but I always gets an error while creating ideal table.
I tried the following query which is running but the ideal table always breaks:
Note: Main purpose for this post is to avoid a hardcoded query, I need a dynamic simple query so please help me.
sql_queries = [
"DROP DATABASE IF EXISTS python_assignment_chishti",
"CREATE DATABASE python_assignment_chishti",
"CREATE TABLE train (id INT AUTO_INCREMENT PRIMARY KEY, x float, y1 float, y2 float, y3 float, y4 float)",
"CREATE TABLE ideal (id INT AUTO_INCREMENT PRIMARY KEY, x FLOAT, ", # Include x column in ideal table definition
*[f"y{i+1} FLOAT," for i in range(1, 50)], # Add y1 to y50 columns with trailing comma
")",
"CREATE TABLE test (id INT AUTO_INCREMENT PRIMARY KEY, x float(255), y float(255))",
"CREATE TABLE best_fit_func (id INT AUTO_INCREMENT PRIMARY KEY, x float(255), y float(255))",
"CREATE TABLE mapping (id INT AUTO_INCREMENT PRIMARY KEY, x float(255), y float(255), a float, b float, deviation float)"
]
mycursor.execute()
here to see error