【发布时间】:2012-09-27 17:06:18
【问题描述】:
希望使用 Django / db-api 的内置字符串扩展,但它似乎不适用于 create database 命令?
from django.db import connections
cursor = connections['dbadmin'].cursor()
cursor.execute('create database %s', ['foo'])
失败了
DatabaseError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''foo'' at line 1")
虽然直接的、未参数化的 create database foo 可以正常工作。
对我来说这看起来像是一个错误,对吧? drop database也有类似的问题...
【问题讨论】:
标签: python sql django sql-injection python-db-api