Question
Create a function with the following signature: def createTableSQL(table_name,fields): Where table_name is a string and fields is a list of strings. It should return a
Create a function with the following signature:
def createTableSQL(table_name,fields):
Where table_name is a string and fields is a list of strings. It should return a SQL string which is the CREATE TABLE SQL required to create the table in a SQL DB. You should use the following general pattern:
CREATE TABLE IF NOT EXISTS `{table_name}` ( `{field1}` varchar(255) NOT NULL, `{field2}` varchar(255) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Your function should be called like this in the Python script you submit:
print(createTableSQL('test_users',['id','name','email','phone','password']))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started