我是一个db傻瓜,我正在为我的django项目设置PostgreSQL.为此,我还使用了psycopg2.不过,数据库很复杂.就我个人而言,我想知道是否有办法在一个地方获得我所有的数据库和用户设置/信息.所以我知道连接到什么以及如何连接(我仍在运行local,所以没有安全问题?).
然而,我似乎没有创建这个数据库的"权限",即使我连接到标准的"管理员"——用户"postgres".用我在安装时输入的密码("pw123").
django-project(settings.py):
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django',
'USER': 'postgres',
'PASSWORD': 'pw123',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
CMD -> python manage.py shell (after importing django.db connection)
>>> cursor = connection.cursor()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Python27\lib\site-packages\django\db\backends\__init__.py", line 165, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "C:\Python27\lib\site-packages\django\db\backends\__init__.py", line 138, in _cursor
self.ensure_connection()
File "C:\Python27\lib\site-packages\django\db\backends\__init__.py", line 133, in ensure_connection
self.connect()
File "C:\Python27\lib\site-packages\django\db\utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Python27\lib\site-packages\django\db\backends\__init__.py", line 133, in ensure_connection
self.connect()
File "C:\Python27\lib\site-packages\django\db\backends\__init__.py", line 122, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Python27\lib\site-packages\django\db\backends\postgresql_psycopg2\base.py", line 134, in get_new_connection
return Database.connect(**conn_params)
File "C:\Python27\lib\site-packages\psycopg2-2.5.4-py2.7-win32.egg\psycopg2\__init__.py", line 164, in connect
conn = _connect(dsn, connection_factory=connection_factory, async=async)
OperationalError: FATAL: database "django" does not exist
我是不是在安装过程中做错了什么?我能改正吗?我应该考虑重新安装所有东西吗?我该怎么做呢?数据库把我搞糊涂了:p