How to substitute variable to query SQL?
问题 I have the following query line: c.execute("""insert into apps (url)""") I have variable url that I try to append in query insert. But U get Mysql sintax error There are two field in table: id - autoincrement and url 回答1: The better question should be "How to substitute value in string?" as the query you are passing to the c.execute() is of the string format. Even better, "How to dynamically format the content of the string?" In python, to do that there are many ways: Using str.format() # Way