Is there any way I can introduce variable for the command of mysql example.execute("create database #var")in python? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Is there any way I can introduce variable for the command of mysql example.execute("create database #var")in python?

1.import mysql. connector 2.mydb=mysql.connector 3.example=mydb.cursor() 4.example. execute("create database #var")

25th Nov 2019, 1:26 PM
Urmi
Urmi - avatar
1 Resposta
+ 1
It's just a string and thus any string formatting technique will work. E.g. example.execute("create database {}".format(var))
25th Nov 2019, 3:00 PM
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½
ŠØŠ°Ń‰Šø Š Š°Š½Š¶Š°Š½ - avatar