Created
July 13, 2014 21:11
-
-
Save maryokhin/0749d31ef9b273b13352 to your computer and use it in GitHub Desktop.
Using the same settings as unittest, but pytest can't connect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/maryokhin/.virtualenvs/backend/bin/python /Applications/PyCharm.app/helpers/pycharm/pytestrunner.py -p pytest_teamcity /Users/maryokhin/Workspace/backend/api/tests/test_comment2.py | |
Testing started at 23:08 ... | |
============================= test session starts ============================== | |
platform darwin -- Python 3.4.1 -- py-1.4.20 -- pytest-2.5.2 | |
plugins: django | |
collected 1 items | |
../../../Users/maryokhin/Workspace/backend/api/tests/test_comment2.py E | |
def setup_module(): | |
> channel = Channel.objects.create(name='test') | |
/Users/maryokhin/Workspace/backend/api/tests/test_comment2.py:6: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.utils.deprecation.ManagerFromChannelQuerySet object at 0x103946780> | |
args = (), kwargs = {'name': 'test'} | |
def manager_method(self, *args, **kwargs): | |
> return getattr(self.get_queryset(), name)(*args, **kwargs) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/models/manager.py:92: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <[OperationalError("FATAL: database "database" does not exist | |
") raised in repr()] ChannelQuerySet object at 0x103bfa978> | |
kwargs = {'name': 'test'}, obj = <Channel: test> | |
def create(self, **kwargs): | |
""" | |
Creates a new object with the given kwargs, saving it to the database | |
and returning the created object. | |
""" | |
obj = self.model(**kwargs) | |
self._for_write = True | |
> obj.save(force_insert=True, using=self.db) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/models/query.py:370: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Channel: test>, force_insert = True, force_update = False | |
using = 'default', update_fields = None | |
def save(self, force_insert=False, force_update=False, using=None, | |
update_fields=None): | |
""" | |
Saves the current instance. Override this in a subclass if you want to | |
control the saving process. | |
The 'force_insert' and 'force_update' parameters can be used to insist | |
that the "save" must be an SQL insert or update (or equivalent for | |
non-SQL backends), respectively. Normally, they should not be set. | |
""" | |
using = using or router.db_for_write(self.__class__, instance=self) | |
if force_insert and (force_update or update_fields): | |
raise ValueError("Cannot force both insert and updating in model saving.") | |
if update_fields is not None: | |
# If update_fields is empty, skip the save. We do also check for | |
# no-op saves later on for inheritance cases. This bailout is | |
# still needed for skipping signal sending. | |
if len(update_fields) == 0: | |
return | |
update_fields = frozenset(update_fields) | |
field_names = set() | |
for field in self._meta.fields: | |
if not field.primary_key: | |
field_names.add(field.name) | |
if field.name != field.attname: | |
field_names.add(field.attname) | |
non_model_fields = update_fields.difference(field_names) | |
if non_model_fields: | |
raise ValueError("The following fields do not exist in this " | |
"model or are m2m fields: %s" | |
% ', '.join(non_model_fields)) | |
# If saving to the same database, and this model is deferred, then | |
# automatically do a "update_fields" save on the loaded fields. | |
elif not force_insert and self._deferred and using == self._state.db: | |
field_names = set() | |
for field in self._meta.concrete_fields: | |
if not field.primary_key and not hasattr(field, 'through'): | |
field_names.add(field.attname) | |
deferred_fields = [ | |
f.attname for f in self._meta.fields | |
if (f.attname not in self.__dict__ and | |
isinstance(self.__class__.__dict__[f.attname], DeferredAttribute)) | |
] | |
loaded_fields = field_names.difference(deferred_fields) | |
if loaded_fields: | |
update_fields = frozenset(loaded_fields) | |
self.save_base(using=using, force_insert=force_insert, | |
> force_update=force_update, update_fields=update_fields) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/models/base.py:590: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Channel: test>, raw = False, force_insert = True, force_update = False | |
using = 'default', update_fields = None | |
def save_base(self, raw=False, force_insert=False, | |
force_update=False, using=None, update_fields=None): | |
""" | |
Handles the parts of saving which should be done only once per save, | |
yet need to be done in raw saves, too. This includes some sanity | |
checks and signal sending. | |
The 'raw' argument is telling save_base not to save any parent | |
models and not to do any changes to the values before save. This | |
is used by fixture loading. | |
""" | |
using = using or router.db_for_write(self.__class__, instance=self) | |
assert not (force_insert and (force_update or update_fields)) | |
assert update_fields is None or len(update_fields) > 0 | |
cls = origin = self.__class__ | |
# Skip proxies, but keep the origin as the proxy model. | |
if cls._meta.proxy: | |
cls = cls._meta.concrete_model | |
meta = cls._meta | |
if not meta.auto_created: | |
signals.pre_save.send(sender=origin, instance=self, raw=raw, using=using, | |
update_fields=update_fields) | |
> with transaction.commit_on_success_unless_managed(using=using, savepoint=False): | |
if not raw: | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/models/base.py:615: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
using = 'default', savepoint = False | |
def commit_on_success_unless_managed(using=None, savepoint=False): | |
""" | |
Transitory API to preserve backwards-compatibility while refactoring. | |
Once the legacy transaction management is fully deprecated, this should | |
simply be replaced by atomic. Until then, it's necessary to guarantee that | |
a commit occurs on exit, which atomic doesn't do when it's nested. | |
Unlike atomic, savepoint defaults to False because that's closer to the | |
legacy behavior. | |
""" | |
connection = get_connection(using) | |
> if connection.get_autocommit() or connection.in_atomic_block: | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/transaction.py:559: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper object at 0x1036e76a0> | |
def get_autocommit(self): | |
""" | |
Check the autocommit state. | |
""" | |
> self.ensure_connection() | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/backends/__init__.py:345: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper object at 0x1036e76a0> | |
def ensure_connection(self): | |
""" | |
Guarantees that a connection to the database is established. | |
""" | |
if self.connection is None: | |
with self.wrap_database_errors: | |
> self.connect() | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/backends/__init__.py:133: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.utils.DatabaseErrorWrapper object at 0x103bfa278> | |
exc_type = <class 'psycopg2.OperationalError'> | |
exc_value = OperationalError('FATAL: database "database" does not exist\n',) | |
traceback = <traceback object at 0x103c17048> | |
def __exit__(self, exc_type, exc_value, traceback): | |
if exc_type is None: | |
return | |
for dj_exc_type in ( | |
DataError, | |
OperationalError, | |
IntegrityError, | |
InternalError, | |
ProgrammingError, | |
NotSupportedError, | |
DatabaseError, | |
InterfaceError, | |
Error, | |
): | |
db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__) | |
if issubclass(exc_type, db_exc_type): | |
dj_exc_value = dj_exc_type(*exc_value.args) | |
dj_exc_value.__cause__ = exc_value | |
# Only set the 'errors_occurred' flag for errors that may make | |
# the connection unusable. | |
if dj_exc_type not in (DataError, IntegrityError): | |
self.wrapper.errors_occurred = True | |
> six.reraise(dj_exc_type, dj_exc_value, traceback) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/utils.py:94: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
tp = <class 'django.db.utils.OperationalError'> | |
value = OperationalError('FATAL: database "database" does not exist\n',) | |
tb = <traceback object at 0x103c17048> | |
def reraise(tp, value, tb=None): | |
if value.__traceback__ is not tb: | |
> raise value.with_traceback(tb) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/utils/six.py:549: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper object at 0x1036e76a0> | |
def ensure_connection(self): | |
""" | |
Guarantees that a connection to the database is established. | |
""" | |
if self.connection is None: | |
with self.wrap_database_errors: | |
> self.connect() | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/backends/__init__.py:133: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper object at 0x1036e76a0> | |
def connect(self): | |
"""Connects to the database. Assumes that the connection is closed.""" | |
# In case the previous connection was closed while in an atomic block | |
self.in_atomic_block = False | |
self.savepoint_ids = [] | |
self.needs_rollback = False | |
# Reset parameters defining when to close the connection | |
max_age = self.settings_dict['CONN_MAX_AGE'] | |
self.close_at = None if max_age is None else time.time() + max_age | |
self.closed_in_transaction = False | |
self.errors_occurred = False | |
# Establish the connection | |
conn_params = self.get_connection_params() | |
> self.connection = self.get_new_connection(conn_params) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/backends/__init__.py:122: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper object at 0x1036e76a0> | |
conn_params = {'database': 'database'} | |
def get_new_connection(self, conn_params): | |
> return Database.connect(**conn_params) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/backends/postgresql_psycopg2/base.py:134: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
dsn = 'dbname=database', database = 'database', user = None, password = None | |
host = None, port = None, connection_factory = None, cursor_factory = None | |
async = False, kwargs = {}, items = [('dbname', 'database')] | |
def connect(dsn=None, | |
database=None, user=None, password=None, host=None, port=None, | |
connection_factory=None, cursor_factory=None, async=False, **kwargs): | |
""" | |
Create a new database connection. | |
The connection parameters can be specified either as a string: | |
conn = psycopg2.connect("dbname=test user=postgres password=secret") | |
or using a set of keyword arguments: | |
conn = psycopg2.connect(database="test", user="postgres", password="secret") | |
The basic connection parameters are: | |
- *dbname*: the database name (only in dsn string) | |
- *database*: the database name (only as keyword argument) | |
- *user*: user name used to authenticate | |
- *password*: password used to authenticate | |
- *host*: database host address (defaults to UNIX socket if not provided) | |
- *port*: connection port number (defaults to 5432 if not provided) | |
Using the *connection_factory* parameter a different class or connections | |
factory can be specified. It should be a callable object taking a dsn | |
argument. | |
Using the *cursor_factory* parameter, a new default cursor factory will be | |
used by cursor(). | |
Using *async*=True an asynchronous connection will be created. | |
Any other keyword parameter will be passed to the underlying client | |
library: the list of supported parameters depends on the library version. | |
""" | |
items = [] | |
if database is not None: | |
items.append(('dbname', database)) | |
if user is not None: | |
items.append(('user', user)) | |
if password is not None: | |
items.append(('password', password)) | |
if host is not None: | |
items.append(('host', host)) | |
if port is not None: | |
items.append(('port', port)) | |
items.extend([(k, v) for (k, v) in kwargs.items() if v is not None]) | |
if dsn is not None and items: | |
raise TypeError( | |
"'%s' is an invalid keyword argument when the dsn is specified" | |
% items[0][0]) | |
if dsn is None: | |
if not items: | |
raise TypeError('missing dsn and no parameters') | |
else: | |
dsn = " ".join(["%s=%s" % (k, _param_escape(str(v))) | |
for (k, v) in items]) | |
> conn = _connect(dsn, connection_factory=connection_factory, async=async) | |
E django.db.utils.OperationalError: FATAL: database "database" does not exist | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/psycopg2/__init__.py:164: OperationalError | |
==================================== ERRORS ==================================== | |
_______________________ ERROR at setup of test_something _______________________ | |
def setup_module(): | |
> channel = Channel.objects.create(name='test') | |
/Users/maryokhin/Workspace/backend/api/tests/test_comment2.py:6: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.utils.deprecation.ManagerFromChannelQuerySet object at 0x103946780> | |
args = (), kwargs = {'name': 'test'} | |
def manager_method(self, *args, **kwargs): | |
> return getattr(self.get_queryset(), name)(*args, **kwargs) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/models/manager.py:92: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <[OperationalError("FATAL: database "database" does not exist | |
") raised in repr()] ChannelQuerySet object at 0x103bfa978> | |
kwargs = {'name': 'test'}, obj = <Channel: test> | |
def create(self, **kwargs): | |
""" | |
Creates a new object with the given kwargs, saving it to the database | |
and returning the created object. | |
""" | |
obj = self.model(**kwargs) | |
self._for_write = True | |
> obj.save(force_insert=True, using=self.db) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/models/query.py:370: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Channel: test>, force_insert = True, force_update = False | |
using = 'default', update_fields = None | |
def save(self, force_insert=False, force_update=False, using=None, | |
update_fields=None): | |
""" | |
Saves the current instance. Override this in a subclass if you want to | |
control the saving process. | |
The 'force_insert' and 'force_update' parameters can be used to insist | |
that the "save" must be an SQL insert or update (or equivalent for | |
non-SQL backends), respectively. Normally, they should not be set. | |
""" | |
using = using or router.db_for_write(self.__class__, instance=self) | |
if force_insert and (force_update or update_fields): | |
raise ValueError("Cannot force both insert and updating in model saving.") | |
if update_fields is not None: | |
# If update_fields is empty, skip the save. We do also check for | |
# no-op saves later on for inheritance cases. This bailout is | |
# still needed for skipping signal sending. | |
if len(update_fields) == 0: | |
return | |
update_fields = frozenset(update_fields) | |
field_names = set() | |
for field in self._meta.fields: | |
if not field.primary_key: | |
field_names.add(field.name) | |
if field.name != field.attname: | |
field_names.add(field.attname) | |
non_model_fields = update_fields.difference(field_names) | |
if non_model_fields: | |
raise ValueError("The following fields do not exist in this " | |
"model or are m2m fields: %s" | |
% ', '.join(non_model_fields)) | |
# If saving to the same database, and this model is deferred, then | |
# automatically do a "update_fields" save on the loaded fields. | |
elif not force_insert and self._deferred and using == self._state.db: | |
field_names = set() | |
for field in self._meta.concrete_fields: | |
if not field.primary_key and not hasattr(field, 'through'): | |
field_names.add(field.attname) | |
deferred_fields = [ | |
f.attname for f in self._meta.fields | |
if (f.attname not in self.__dict__ and | |
isinstance(self.__class__.__dict__[f.attname], DeferredAttribute)) | |
] | |
loaded_fields = field_names.difference(deferred_fields) | |
if loaded_fields: | |
update_fields = frozenset(loaded_fields) | |
self.save_base(using=using, force_insert=force_insert, | |
> force_update=force_update, update_fields=update_fields) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/models/base.py:590: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <Channel: test>, raw = False, force_insert = True, force_update = False | |
using = 'default', update_fields = None | |
def save_base(self, raw=False, force_insert=False, | |
force_update=False, using=None, update_fields=None): | |
""" | |
Handles the parts of saving which should be done only once per save, | |
yet need to be done in raw saves, too. This includes some sanity | |
checks and signal sending. | |
The 'raw' argument is telling save_base not to save any parent | |
models and not to do any changes to the values before save. This | |
is used by fixture loading. | |
""" | |
using = using or router.db_for_write(self.__class__, instance=self) | |
assert not (force_insert and (force_update or update_fields)) | |
assert update_fields is None or len(update_fields) > 0 | |
cls = origin = self.__class__ | |
# Skip proxies, but keep the origin as the proxy model. | |
if cls._meta.proxy: | |
cls = cls._meta.concrete_model | |
meta = cls._meta | |
if not meta.auto_created: | |
signals.pre_save.send(sender=origin, instance=self, raw=raw, using=using, | |
update_fields=update_fields) | |
> with transaction.commit_on_success_unless_managed(using=using, savepoint=False): | |
if not raw: | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/models/base.py:615: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
using = 'default', savepoint = False | |
def commit_on_success_unless_managed(using=None, savepoint=False): | |
""" | |
Transitory API to preserve backwards-compatibility while refactoring. | |
Once the legacy transaction management is fully deprecated, this should | |
simply be replaced by atomic. Until then, it's necessary to guarantee that | |
a commit occurs on exit, which atomic doesn't do when it's nested. | |
Unlike atomic, savepoint defaults to False because that's closer to the | |
legacy behavior. | |
""" | |
connection = get_connection(using) | |
> if connection.get_autocommit() or connection.in_atomic_block: | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/transaction.py:559: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper object at 0x1036e76a0> | |
def get_autocommit(self): | |
""" | |
Check the autocommit state. | |
""" | |
> self.ensure_connection() | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/backends/__init__.py:345: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper object at 0x1036e76a0> | |
def ensure_connection(self): | |
""" | |
Guarantees that a connection to the database is established. | |
""" | |
if self.connection is None: | |
with self.wrap_database_errors: | |
> self.connect() | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/backends/__init__.py:133: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.utils.DatabaseErrorWrapper object at 0x103bfa278> | |
exc_type = <class 'psycopg2.OperationalError'> | |
exc_value = OperationalError('FATAL: database "database" does not exist\n',) | |
traceback = <traceback object at 0x103c17048> | |
def __exit__(self, exc_type, exc_value, traceback): | |
if exc_type is None: | |
return | |
for dj_exc_type in ( | |
DataError, | |
OperationalError, | |
IntegrityError, | |
InternalError, | |
ProgrammingError, | |
NotSupportedError, | |
DatabaseError, | |
InterfaceError, | |
Error, | |
): | |
db_exc_type = getattr(self.wrapper.Database, dj_exc_type.__name__) | |
if issubclass(exc_type, db_exc_type): | |
dj_exc_value = dj_exc_type(*exc_value.args) | |
dj_exc_value.__cause__ = exc_value | |
# Only set the 'errors_occurred' flag for errors that may make | |
# the connection unusable. | |
if dj_exc_type not in (DataError, IntegrityError): | |
self.wrapper.errors_occurred = True | |
> six.reraise(dj_exc_type, dj_exc_value, traceback) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/utils.py:94: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
tp = <class 'django.db.utils.OperationalError'> | |
value = OperationalError('FATAL: database "database" does not exist\n',) | |
tb = <traceback object at 0x103c17048> | |
def reraise(tp, value, tb=None): | |
if value.__traceback__ is not tb: | |
> raise value.with_traceback(tb) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/utils/six.py:549: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper object at 0x1036e76a0> | |
def ensure_connection(self): | |
""" | |
Guarantees that a connection to the database is established. | |
""" | |
if self.connection is None: | |
with self.wrap_database_errors: | |
> self.connect() | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/backends/__init__.py:133: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper object at 0x1036e76a0> | |
def connect(self): | |
"""Connects to the database. Assumes that the connection is closed.""" | |
# In case the previous connection was closed while in an atomic block | |
self.in_atomic_block = False | |
self.savepoint_ids = [] | |
self.needs_rollback = False | |
# Reset parameters defining when to close the connection | |
max_age = self.settings_dict['CONN_MAX_AGE'] | |
self.close_at = None if max_age is None else time.time() + max_age | |
self.closed_in_transaction = False | |
self.errors_occurred = False | |
# Establish the connection | |
conn_params = self.get_connection_params() | |
> self.connection = self.get_new_connection(conn_params) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/backends/__init__.py:122: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <django.db.backends.postgresql_psycopg2.base.DatabaseWrapper object at 0x1036e76a0> | |
conn_params = {'database': 'database'} | |
def get_new_connection(self, conn_params): | |
> return Database.connect(**conn_params) | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/django/db/backends/postgresql_psycopg2/base.py:134: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
dsn = 'dbname=database', database = 'database', user = None, password = None | |
host = None, port = None, connection_factory = None, cursor_factory = None | |
async = False, kwargs = {}, items = [('dbname', 'database')] | |
def connect(dsn=None, | |
database=None, user=None, password=None, host=None, port=None, | |
connection_factory=None, cursor_factory=None, async=False, **kwargs): | |
""" | |
Create a new database connection. | |
The connection parameters can be specified either as a string: | |
conn = psycopg2.connect("dbname=test user=postgres password=secret") | |
or using a set of keyword arguments: | |
conn = psycopg2.connect(database="test", user="postgres", password="secret") | |
The basic connection parameters are: | |
- *dbname*: the database name (only in dsn string) | |
- *database*: the database name (only as keyword argument) | |
- *user*: user name used to authenticate | |
- *password*: password used to authenticate | |
- *host*: database host address (defaults to UNIX socket if not provided) | |
- *port*: connection port number (defaults to 5432 if not provided) | |
Using the *connection_factory* parameter a different class or connections | |
factory can be specified. It should be a callable object taking a dsn | |
argument. | |
Using the *cursor_factory* parameter, a new default cursor factory will be | |
used by cursor(). | |
Using *async*=True an asynchronous connection will be created. | |
Any other keyword parameter will be passed to the underlying client | |
library: the list of supported parameters depends on the library version. | |
""" | |
items = [] | |
if database is not None: | |
items.append(('dbname', database)) | |
if user is not None: | |
items.append(('user', user)) | |
if password is not None: | |
items.append(('password', password)) | |
if host is not None: | |
items.append(('host', host)) | |
if port is not None: | |
items.append(('port', port)) | |
items.extend([(k, v) for (k, v) in kwargs.items() if v is not None]) | |
if dsn is not None and items: | |
raise TypeError( | |
"'%s' is an invalid keyword argument when the dsn is specified" | |
% items[0][0]) | |
if dsn is None: | |
if not items: | |
raise TypeError('missing dsn and no parameters') | |
else: | |
dsn = " ".join(["%s=%s" % (k, _param_escape(str(v))) | |
for (k, v) in items]) | |
> conn = _connect(dsn, connection_factory=connection_factory, async=async) | |
E django.db.utils.OperationalError: FATAL: database "database" does not exist | |
/Users/maryokhin/.virtualenvs/backend/lib/python3.4/site-packages/psycopg2/__init__.py:164: OperationalError | |
=========================== 1 error in 0.11 seconds ============================ | |
Process finished with exit code 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment