Can I insert plenty of values into a table without a lot of redundant character in python?

I want to insert a row in a table by a python code with all of the columns. I can do this for example:

"INSERT INTO TableName VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"....

Must I use a lot of ? in the sql when I want to insert eg.: 11 column data? Is there any shorter and easier way for it? Additional information: In this case I gave all column data in the sql so luckily I didn't have to write the name of the all columns. :)

What can I do for example, when I want to insert 1 row with 100 column data into a table?

Answer Answered by Daniel Black in this comment.

Use the fully featured python string functions like

"INSERT INTO table VALUES (" + ",".join("?" * 100) + ")"

100 columns however makes me question if you've normalized your data correctly.

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.