从sqlite3转换为postgresql

时间:2018-02-27 13:44:30

标签: python django database postgresql psycopg2

我尝试使用本教程将我的数据库从sqlite3更改为postgresql:

https://tutorial-extensions.djangogirls.org/en/optional_postgresql_installation/

但是当我尝试迁移时,我收到以下错误

Traceback (most recent call last):
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\backends\base\base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\backends\postgresql\base.py", line 176, in get_new_connection
    connection = Database.connect(**conn_params)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
psycopg2\__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\core\management\__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\core\management\__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\core\management\base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\core\management\commands\migrate.py", line 83, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\migrations\executor.py", line 20, in __init__
    self.loader = MigrationLoader(self.connection)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\migrations\loader.py", line 52, in __init__
    self.build_graph()
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\migrations\loader.py", line 209, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\migrations\recorder.py", line 65, in applied_migrations
    self.ensure_schema()
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\migrations\recorder.py", line 52, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.table_name
s(self.connection.cursor()):
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\backends\base\base.py", line 254, in cursor
    return self._cursor()
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\backends\base\base.py", line 229, in _cursor
    self.ensure_connection()
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\backends\base\base.py", line 213, in ensure_connection
    self.connect()
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\backends\base\base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
django\db\backends\postgresql\base.py", line 176, in get_new_connection
    connection = Database.connect(**conn_params)
  File "c:\Users\gudat\Documents\Arbeit\Szenario\Python\venv1\lib\site-packages\
psycopg2\__init__.py", line 130, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError

在我的settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'dbase',
        'USER': 'name',
        'PASSWORD': 'test',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

(是的,我更改了名称) 使用Python 3.6.3和psycopg2(2.7.4)。

我做错了什么?

0 个答案:

没有答案