SQLite 到 PostgreSQL 问题 [wagtail 教程]
SQLite to PostgreSQL issue [wagtail tutorial]
这是我第一次将我的 wagtail 应用程序(我为此感到非常自豪 :) )到 heroku。我正在学习本教程(请参阅下面的 link):
https://wagtail.io/blog/deploying-wagtail-heroku/
但是我在这个教程中遇到了一个麻烦:
这是当我将 sqlite 之间的数据库更改为 PostgreSQL.
有问题:
django.db.utils.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
我在 mac os 10.13.3。 Python 与 Anaconda。
这就是我所做的:
- 在 base.py 文件中将默认端口更改为 5433 但它不起作用。(如本教程:https://vix.digital/insights/deploying-wagtail-production/)
- 试图找到并修改 .conf 文件,但没有找到...
在此之前,没有安装以前的postgresql。我没有任何 postgres 服务器 运行(我不知道如何检查它,但我卡在了本教程的第一步...)。
感谢您的帮助! :)
整个终端响应
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 12, in <module>
execute_from_command_line(sys.argv)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 83, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/migrations/loader.py", line 52, in __init__
self.build_graph()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/migrations/loader.py", line 209, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/Users/darkbook/anaconda3/lib/python3.6/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 "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 254, in cursor
return self._cursor()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 229, in _cursor
self.ensure_connection()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
connection = Database.connect(**conn_params)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
如果您没有任何 PostgreSQL 服务器 运行 那么错误消息 "Is the server running locally?" 中的建议非常有用! :)
由于您使用的是 OS X,我推荐 https://postgresapp.com 作为开始使用 PostgreSQL 的最简单方法。
请注意,虽然有充分的理由在两个地方使用相同的设置,但可以在本地使用 SQLite 开发项目,并在 Heroku 上使用 PostgreSQL。
您需要先创建 Postgres 数据库,然后才能连接到它最简单的方法是使用 Postico:https://eggerapps.at/postico/
在 Postico 中创建数据库(例如数据库名称 "mysite"),然后在您的 base.py 设置中,您会得到如下内容:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mysite',
'USER': '', # e.g 'postgres'
'PASSWORD': '',
'HOST': '', # Set to empty string for localhost.
'PORT': '', # Set to empty string for default.
'CONN_MAX_AGE': 600, # number of seconds database connections should persist for
}
}
不要忘记您需要再次 运行 迁移以构建所有表。所以从 manage.py 开始,你会 运行 makemigrations
然后 migrate
.
这是我第一次将我的 wagtail 应用程序(我为此感到非常自豪 :) )到 heroku。我正在学习本教程(请参阅下面的 link): https://wagtail.io/blog/deploying-wagtail-heroku/
但是我在这个教程中遇到了一个麻烦: 这是当我将 sqlite 之间的数据库更改为 PostgreSQL.
有问题:
django.db.utils.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
我在 mac os 10.13.3。 Python 与 Anaconda。
这就是我所做的:
- 在 base.py 文件中将默认端口更改为 5433 但它不起作用。(如本教程:https://vix.digital/insights/deploying-wagtail-production/)
- 试图找到并修改 .conf 文件,但没有找到...
在此之前,没有安装以前的postgresql。我没有任何 postgres 服务器 运行(我不知道如何检查它,但我卡在了本教程的第一步...)。
感谢您的帮助! :)
整个终端响应
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 12, in <module>
execute_from_command_line(sys.argv)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 83, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/migrations/loader.py", line 52, in __init__
self.build_graph()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/migrations/loader.py", line 209, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/Users/darkbook/anaconda3/lib/python3.6/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 "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 254, in cursor
return self._cursor()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 229, in _cursor
self.ensure_connection()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
connection = Database.connect(**conn_params)
File "/Users/darkbook/anaconda3/lib/python3.6/site-packages/psycopg2/__init__.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
如果您没有任何 PostgreSQL 服务器 运行 那么错误消息 "Is the server running locally?" 中的建议非常有用! :)
由于您使用的是 OS X,我推荐 https://postgresapp.com 作为开始使用 PostgreSQL 的最简单方法。
请注意,虽然有充分的理由在两个地方使用相同的设置,但可以在本地使用 SQLite 开发项目,并在 Heroku 上使用 PostgreSQL。
您需要先创建 Postgres 数据库,然后才能连接到它最简单的方法是使用 Postico:https://eggerapps.at/postico/
在 Postico 中创建数据库(例如数据库名称 "mysite"),然后在您的 base.py 设置中,您会得到如下内容:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mysite',
'USER': '', # e.g 'postgres'
'PASSWORD': '',
'HOST': '', # Set to empty string for localhost.
'PORT': '', # Set to empty string for default.
'CONN_MAX_AGE': 600, # number of seconds database connections should persist for
}
}
不要忘记您需要再次 运行 迁移以构建所有表。所以从 manage.py 开始,你会 运行 makemigrations
然后 migrate
.