Python psycopg2.InternalError无论我做什么

Python psycopg2.InternalError无论我做什么,python,django,Python,Django,我使用Django,只是删除并重新创建了数据库,以便刷新表数据。现在,当我尝试执行任何与数据库相关的任务时,我得到: ./manage.py sql portfolio Traceback (most recent call last): File "./manage.py", line 11, in <module> execute_manager(settings) File "/usr/lib/pymodules/python2.6/django/core/ma

我使用Django,只是删除并重新创建了数据库,以便刷新表数据。现在,当我尝试执行任何与数据库相关的任务时,我得到:

./manage.py sql portfolio
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 362, in execute_manager
    utility.execute()
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 303, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 195, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 222, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/pymodules/python2.6/django/core/management/base.py", line 286, in handle
    app_output = self.handle_app(app, **options)
  File "/usr/lib/pymodules/python2.6/django/core/management/commands/sql.py", line 10, in handle_app
    return u'\n'.join(sql_create(app, self.style)).encode('utf-8')
  File "/usr/lib/pymodules/python2.6/django/core/management/sql.py", line 28, in sql_create
    tables = connection.introspection.table_names()
  File "/usr/lib/pymodules/python2.6/django/db/backends/__init__.py", line 491, in table_names
    return self.get_table_list(cursor)
  File "/usr/lib/pymodules/python2.6/django/db/backends/postgresql/introspection.py", line 30, in get_table_list
    AND pg_catalog.pg_table_is_visible(c.oid)""")
  File "/usr/lib/pymodules/python2.6/django/db/backends/util.py", line 19, in execute
    return self.cursor.execute(sql, params)
psycopg2.InternalError: BŁĄD:  current transaction is aborted, commands ignored until end of transaction block
/manage.py sql组合
回溯(最近一次呼叫最后一次):
文件“/manage.py”,第11行,在
执行\u管理器(设置)
文件“/usr/lib/pymodules/python2.6/django/core/management/_init__.py”,第362行,在执行管理器中
utility.execute()
文件“/usr/lib/pymodules/python2.6/django/core/management/_init__.py”,执行中第303行
self.fetch_命令(子命令)。从_argv(self.argv)运行_
文件“/usr/lib/pymodules/python2.6/django/core/management/base.py”,第195行,从_argv运行
self.execute(*args,**选项._dict__;
文件“/usr/lib/pymodules/python2.6/django/core/management/base.py”,执行中的第222行
输出=self.handle(*args,**选项)
文件“/usr/lib/pymodules/python2.6/django/core/management/base.py”,第286行,在handle中
app\u output=self.handle\u app(app,**选项)
handle_应用程序中的文件“/usr/lib/pymodules/python2.6/django/core/management/commands/sql.py”,第10行
返回u'\n'.join(sql\u create(app,self.style)).encode('utf-8')
文件“/usr/lib/pymodules/python2.6/django/core/management/sql.py”,第28行,在sql\u create中
tables=connection.introspection.table_names()
文件“/usr/lib/pymodules/python2.6/django/db/backends/_init__.py”,第491行,表_名称中
返回self.get\u表\u列表(光标)
文件“/usr/lib/pymodules/python2.6/django/db/backends/postgresql/introspection.py”,第30行,在get_table_列表中
和pg_目录。pg_表_是可见的(c.oid)“”)
文件“/usr/lib/pymodules/python2.6/django/db/backends/util.py”,执行中的第19行
返回self.cursor.execute(sql,params)
psycopg2.InternalError:BŁĄD:当前事务被中止,在事务块结束之前忽略命令

正如您所看到的,它只是代码生成,所以事务不应该有任何问题。发生了什么?-(

< P>)错误意味着在PASGRESS进程中发生了一些事情,导致事务在事务中间失败,但是事务从未提交或回滚,所以它被卡住了。 基本上,您需要发出回滚命令(通常可以从Django shell执行),或者终止postgres进程

请注意(取决于您的服务器配置),即使Django没有运行,Postgres进程也会继续运行,因此每次都会出现相同的错误,因为它可能仍然停留在同一进程中


如果您已经这样做了,但每次它仍然这样做,那么这意味着您在某个地方触发了实际代码中的错误,需要进行挖掘。

检查postgres日志文件,查看导致数据库错误的实际查询。并尝试查找django的哪个部分进行了此查询

也请查收。
它说django debug toolbar可能是此错误的原因。请尝试禁用它。

仍然会出现此错误,但我可以通过临时添加:def get_table_list(self,cursor):return[]”来创建SQL。返回当前数据库中的表名列表。“在文件/usr/lib/pymodules/python2.6/django/db/backends/postgresql/introspection.py中,当使用其他命令时仍然会出错。这也发生在我身上,这与模型有关。使用mysql后端更为宽容,但我认为肯定会发生一些奇怪的事情。