当前位置: 首页>>代码示例>>Python>>正文


Python Env.db_url_config方法代码示例

本文整理汇总了Python中environ.Env.db_url_config方法的典型用法代码示例。如果您正苦于以下问题:Python Env.db_url_config方法的具体用法?Python Env.db_url_config怎么用?Python Env.db_url_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在environ.Env的用法示例。


在下文中一共展示了Env.db_url_config方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_database_options_parsing

# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url_config [as 别名]
    def test_database_options_parsing(self):
        url = 'postgres://user:[email protected]:1234/dbname?conn_max_age=600'
        url = Env.db_url_config(url)
        self.assertEqual(url['CONN_MAX_AGE'], 600)

        url = 'mysql://user:[email protected]:1234/dbname?init_command=SET storage_engine=INNODB'
        url = Env.db_url_config(url)
        self.assertEqual(url['OPTIONS'], {
            'init_command': 'SET storage_engine=INNODB',
        })
开发者ID:AliLozano,项目名称:django-environ,代码行数:12,代码来源:test.py

示例2: test_database_options_parsing

# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url_config [as 别名]
    def test_database_options_parsing(self):
        url = 'postgres://user:[email protected]:1234/dbname?conn_max_age=600'
        url = Env.db_url_config(url)
        self.assertEqual(url['CONN_MAX_AGE'], 600)

        url = 'postgres://user:[email protected]:1234/dbname?conn_max_age=None&autocommit=True&atomic_requests=False'
        url = Env.db_url_config(url)
        self.assertEqual(url['CONN_MAX_AGE'], None)
        self.assertEqual(url['AUTOCOMMIT'], True)
        self.assertEqual(url['ATOMIC_REQUESTS'], False)

        url = 'mysql://user:[email protected]:1234/dbname?init_command=SET storage_engine=INNODB'
        url = Env.db_url_config(url)
        self.assertEqual(url['OPTIONS'], {
            'init_command': 'SET storage_engine=INNODB',
        })
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:18,代码来源:test.py

示例3: test_postgres_parsing_unix_domain_socket

# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url_config [as 别名]
    def test_postgres_parsing_unix_domain_socket(self):
        url = 'postgres:////var/run/postgresql/db'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], DJANGO_POSTGRES)
        self.assertEqual(url['NAME'], 'db')
        self.assertEqual(url['HOST'], '/var/run/postgresql')
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:9,代码来源:test.py

示例4: test_memory_sqlite_url_warns_about_netloc

# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url_config [as 别名]
 def test_memory_sqlite_url_warns_about_netloc(self):
     url = 'sqlite://missing-slash-path'
     with warnings.catch_warnings(record=True) as w:
         url = Env.db_url_config(url)
         self.assertEqual(url['ENGINE'], 'django.db.backends.sqlite3')
         self.assertEqual(url['NAME'], ':memory:')
         self.assertEqual(len(w), 1)
         self.assertTrue(issubclass(w[0].category, UserWarning))
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:10,代码来源:test.py

示例5: test_database_ldap_url

# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url_config [as 别名]
    def test_database_ldap_url(self):
        url = 'ldap://cn=admin,dc=nodomain,dc=org:[email protected]/'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], 'ldapdb.backends.ldap')
        self.assertEqual(url['HOST'], 'ldap.nodomain.org')
        self.assertEqual(url['PORT'], None)
        self.assertEqual(url['NAME'], 'ldap://ldap.nodomain.org')
        self.assertEqual(url['USER'], 'cn=admin,dc=nodomain,dc=org')
        self.assertEqual(url['PASSWORD'], 'some_secret_password')
开发者ID:AliLozano,项目名称:django-environ,代码行数:12,代码来源:test.py

示例6: test_cleardb_parsing

# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url_config [as 别名]
    def test_cleardb_parsing(self):
        url = 'mysql://bea6eb025ca0d8:[email protected]/heroku_97681db3eff7580?reconnect=true'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], 'django.db.backends.mysql')
        self.assertEqual(url['NAME'], 'heroku_97681db3eff7580')
        self.assertEqual(url['HOST'], 'us-cdbr-east.cleardb.com')
        self.assertEqual(url['USER'], 'bea6eb025ca0d8')
        self.assertEqual(url['PASSWORD'], '69772142')
        self.assertEqual(url['PORT'], None)
开发者ID:AliLozano,项目名称:django-environ,代码行数:12,代码来源:test.py

示例7: test_mysql_gis_parsing

# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url_config [as 别名]
    def test_mysql_gis_parsing(self):
        url = 'mysqlgis://uf07k1i6d8ia0v:[email protected]:5431/d8r82722r2kuvn'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], 'django.contrib.gis.db.backends.mysql')
        self.assertEqual(url['NAME'], 'd8r82722r2kuvn')
        self.assertEqual(url['HOST'], 'ec2-107-21-253-135.compute-1.amazonaws.com')
        self.assertEqual(url['USER'], 'uf07k1i6d8ia0v')
        self.assertEqual(url['PASSWORD'], 'wegauwhgeuioweg')
        self.assertEqual(url['PORT'], 5431)
开发者ID:AliLozano,项目名称:django-environ,代码行数:12,代码来源:test.py

示例8: test_postgres_parsing

# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url_config [as 别名]
    def test_postgres_parsing(self):
        url = 'postgres://uf07k1i6d8ia0v:[email protected]:5431/d8r82722r2kuvn'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], DJANGO_POSTGRES)
        self.assertEqual(url['NAME'], 'd8r82722r2kuvn')
        self.assertEqual(url['HOST'], 'ec2-107-21-253-135.compute-1.amazonaws.com')
        self.assertEqual(url['USER'], 'uf07k1i6d8ia0v')
        self.assertEqual(url['PASSWORD'], 'wegauwhgeuioweg')
        self.assertEqual(url['PORT'], 5431)
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:12,代码来源:test.py

示例9: test_memory_sqlite_url

# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import db_url_config [as 别名]
    def test_memory_sqlite_url(self):
        url = 'sqlite://:memory:'
        url = Env.db_url_config(url)

        self.assertEqual(url['ENGINE'], 'django.db.backends.sqlite3')
        self.assertEqual(url['NAME'], ':memory:')
开发者ID:AliLozano,项目名称:django-environ,代码行数:8,代码来源:test.py


注:本文中的environ.Env.db_url_config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。