如何解决如何在 Django 中使用自省动态创建模型?
您好,想使用自省创建一个数据库模型。
当我运行 introspection.get_table_description(cursor,'someModeLName')
引发了 TableDoesNotExist(table)
错误。这是如何创建模型还是我完全错了?
Traceback (most recent call last):
File "<console>",line 1,in <module>
File "/usr/local/lib/python3.8/site-packages/django/db/backends/postgresql/introspection.py",line 81,in get_table_description
cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name))
File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py",line 100,in execute
return super().execute(sql,params)
File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py",line 68,in execute
return self._execute_with_wrappers(sql,params,many=False,executor=self._execute)
File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py",line 77,in _execute_with_wrappers
return executor(sql,many,context)
File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py",line 86,in _execute
return self.cursor.execute(sql,params)
File "/usr/local/lib/python3.8/site-packages/django/db/utils.py",line 90,in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py",line 84,in _execute
return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "shapefile_1" does not exist
LINE 1: SELECT * FROM "shapefile_1" LIMIT 1
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。