sql = INSERT INTO LBook 图书ID 书名 作者 出版社 出版年月 价格 是否借出 VALUESs s s s s s s bookid bookname author chubanshe time price lendornot上述代码有误解请修改下面代码是可行的:sql = select from lad where username=;formatus
sql = "INSERT INTO LBook (图书ID, 书名, 作者, 出版社, 出版年月, 价格, 是否借出)
VALUES('{}', '{}', '{}', '{}', '{}', '{}', '{}')".format(bookid, bookname, author, chubanshe, time, price, lendornot)
Explanation:
- The column names in the INSERT INTO statement should not be enclosed in single quotes. Therefore, '图书ID', '书名', '作者', '出版社', '出版年月', '价格', '是否借出' should be changed to just 图书ID, 书名, 作者, 出版社, 出版年月, 价格, 是否借出.
- Instead of using %s placeholders, we can use {} placeholders and then use .format() method to replace them with actual values.
- There is no need to use backslashes to continue the statement in a new line.
- The SELECT statement is correct and doesn't need any modification
原文地址: http://www.cveoy.top/t/topic/hmpZ 著作权归作者所有。请勿转载和采集!