+ 1

MySQL placeholder

For example . . . name = input ('Enter your name') Age = input('Enter your age') Sql_query = ' INSERT INTO tb_name ( col_one, col_two) VALUES ()' D = c.execute(sql_query) F = c.fetchall() Print(F) I don't know how to put a placeholder in the values bracket, so I can insert the users input into the database table

28th Feb 2019, 9:02 AM
Joseph Ojo
Joseph Ojo - avatar
1 Resposta
+ 1
Try using f-strings. Sql_query='INSERT INTO tb_name(col_one, col_two) VALUES(f"{name}, {age}")'
1st Mar 2019, 3:31 AM
Steven M
Steven M - avatar