本文整理汇总了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',
})
示例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',
})
示例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')
示例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))
示例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')
示例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)
示例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)
示例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)
示例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:')