Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Readme
Parse dsn connection url strings. Responsible for parsing dsn strings in projects like prom and morp.
This is a generic version of dj-database-url.
So, now you can create dsns like this:
scheme://user:pass@host:port/path?query=query_val#fragment
For example, let's look at a prom dsn:
prom.interface.postgres.Interface://testuser:testpw@localhost/testdb
Now let's parse it:
import dsnparse
dsn = "prom.interface.postgres.Interface://testuser:testpw@localhost:1234/testdb"
r = dsnparse.parse(dsn)
print(r.scheme) # prom.interface.postgres.Interface
print(r.username) # testuser
print(r.password) # testpw
print(r.host) # localhost
print(r.port) # 1234
print(r.hostloc) # localhost:1234
print(r.paths) # ['testdb']
Also, dsnparse can easily use environment variables:
r = dsnparse.parse_environ('ENVIRONMENT_VARIABLE_NAME')
I tried to keep the interface very similar to urlparse so it will feel familiar to use.
By default, dsnparse.parse(dsn)
returns a ParseResult
instance, but that can be customized:
import dsnparse
class MyResult(dsnparse.ParseResult):
def configure(self):
# expose an interface property
self.interface = self.scheme
dsn = "Interface://testuser:testpw@localhost:1234/testdb"
r = dsnparse.parse(dsn, parse_class=MyResult)
print(isinstance(r, MyResult)) # True
print(r.interface) # Interface
Use pip:
pip install dsnparse
or use pip with github:
pip install -U "git+https://github.com/Jaymon/dsnparse#egg=dsnparse"
FAQs
parse dsn urls
We found that dsnparse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.