예제 #1
0
nydus.contrib.django
~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2011 DISQUS.
:license: Apache License 2.0, see LICENSE for more details.
"""

from __future__ import absolute_import

from nydus import conf
from nydus.db.backends import BaseConnection
from nydus.utils import import_string

from django.conf import settings

conf.configure(getattr(settings, 'NYDUS_CONFIG', {}))


class DjangoDatabase(BaseConnection):
    def __init__(self,
                 backend,
                 name,
                 host=None,
                 port=None,
                 test_name=None,
                 user=None,
                 password=None,
                 options={},
                 **kwargs):
        """
        Given an alias (which is defined in DATABASES), creates a new connection
예제 #2
0
파일: __init__.py 프로젝트: gjcourt/nydus
nydus.contrib.django
~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2011 DISQUS.
:license: Apache License 2.0, see LICENSE for more details.
"""

from __future__ import absolute_import

from nydus import conf
from nydus.db.backends import BaseConnection
from nydus.utils import import_string

from django.conf import settings

conf.configure(getattr(settings, 'NYDUS_CONFIG', {}))

class DjangoDatabase(BaseConnection):
    def __init__(self, backend, name, host=None, port=None, test_name=None, 
                       user=None, password=None, options={}, **kwargs):
        """
        Given an alias (which is defined in DATABASES), creates a new connection
        that proxies the original database engine.
        """
        if isinstance(backend, basestring):
            backend = import_string(backend)
        self.backend = backend
        self.settings_dict = {
            'HOST': host,
            'PORT': port,
            'NAME': name,
예제 #3
0
파일: base.py 프로젝트: disqus/nydus-django
def configure(settings):
    connections = getattr(settings, 'NYDUS_CONNECTIONS', {})

    conf.configure({'CONNECTIONS': connections})