inspectdb命令但它不起作用
我想使用现有的mssql数据库。我用inspectdb命令,但它不工作inspectdb命令但它不起作用
这是我的数据库配置:
DATABASES = {
'default': {
'NAME': 'xxxx',
'ENGINE': 'sqlserver_ado',
'HOST': '102.35.140.54\SQLEXPRESS',
'USER': 'xxxx',
'PASSWORD': 'xxxxx',
'PORT' : '1434',
'OPTIONS': {
'provider': 'SQLNCLI11',
}
}
}
我解雇python manage.py inspectdb
,并得到错误。
D:\Python_Workspace\oracle>python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Python35\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "C:\Python35\lib\site-packages\django\core\management\__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python35\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Python35\lib\site-packages\django\core\management\base.py", line 345, in execute
output = self.handle(*args, **options)
File "C:\Python35\lib\site-packages\django\core\management\commands\migrate.py", line 83, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "C:\Python35\lib\site-packages\django\db\migrations\executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "C:\Python35\lib\site-packages\django\db\migrations\loader.py", line 52, in __init__
self.build_graph()
File "C:\Python35\lib\site-packages\django\db\migrations\loader.py", line 203, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "C:\Python35\lib\site-packages\django\db\migrations\recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "C:\Python35\lib\site-packages\django\db\migrations\recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "C:\Python35\lib\site-packages\django\db\backends\base\base.py", line 231, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "C:\Python35\lib\site-packages\django\db\backends\base\base.py", line 204, in _cursor
self.ensure_connection()
File "C:\Python35\lib\site-packages\django\db\backends\base\base.py", line 199, in ensure_connection
self.connect()
File "C:\Python35\lib\site-packages\django\db\backends\base\base.py", line 170, in connect
conn_params = self.get_connection_params()
File "C:\Python35\lib\site-packages\sqlserver_ado\base.py", line 225, in get_connection_params
'connection_string': make_connection_string(settings_dict),
File "C:\Python35\lib\site-packages\sqlserver_ado\base.py", line 56, in make_connection_string
raise ImproperlyConfigured("When using DATABASE PORT, DATABASE HOST must be an IP address.")
django.core.exceptions.ImproperlyConfigured: When using DATABASE PORT, DATABASE HOST must be an IP address.
问题出在settings.py文件中的数据库设置中。它存在拼写错误。
定义DB的设置是这样的:
DATABASES = {
'default': {
'NAME': 'xxxx',
'ENGINE': 'sqlserver_ado',
'HOST': '102.35.140.54',
'USER': 'xxxx',
'PASSWORD': 'xxxxx',
'PORT' : '1434',
'OPTIONS': {
'provider': 'SQLNCLI11',
}
}
}
为了更好的做法,只使用IP地址,主机'HOST': '102.35.140.54'。
其工作,但得到以下错误。 >>>命令: SELECT * FROM [NI_PI_BASE_MST],其中1 = 0 参数: [] #无法检查表 'NI_PI_BUDGET_MST' #错误是: '异常发生'(-2147352567,(0, 'Microsoft SQL Server Native Client 11.0','无效的对象名称'NI_PI_BUDGET_MST'“,None,0,-2147217865),None)
@RohitKhadatkar我没有任何有关您的数据库的信息。无法帮助你解决这个错误。也许你可以为此提出一个单独的问题。 –
嗨请检查分贝主机请使用IP或主机名称 –