Skip to content
Advertisement

How to add placeholder in python for creating table name in mysql database?

here i want to name the table name according to user desire but i can’t please help

** I HAVE INCLUDED THIS CODES FOR CONNECTING PYTHON TO DATABASE **

Advertisement

Answer

The syntax for creating a table in mySql looks like this:

This will create the table named “my_table_name” with one column named “my_first_column” of type integer.

To implement this in you can use string formatting

or if you’re using >Python3.7 you can use handy f-strings

You should also consider sanitzing the users input k to prohibit an SQL-injection.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement