希望使用 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
有类似的问题...