{"id":16444917,"url":"https://github.com/jaymon/dsnparse","last_synced_at":"2025-02-27T06:14:59.032Z","repository":{"id":10548948,"uuid":"12747255","full_name":"Jaymon/dsnparse","owner":"Jaymon","description":"Easily parse DSN urls (connection strings) in Python","archived":false,"fork":false,"pushed_at":"2024-08-28T22:06:13.000Z","size":64,"stargazers_count":22,"open_issues_count":2,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-20T05:16:18.471Z","etag":null,"topics":["connection","dsn","parse","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jaymon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-09-11T04:08:37.000Z","updated_at":"2025-01-22T02:44:31.000Z","dependencies_parsed_at":"2024-11-24T19:04:43.572Z","dependency_job_id":"046bc5f7-c9a0-4545-aa9a-c59be3a3f455","html_url":"https://github.com/Jaymon/dsnparse","commit_stats":{"total_commits":39,"total_committers":5,"mean_commits":7.8,"dds":0.3076923076923077,"last_synced_commit":"2bb8fb3e168b13620e745822519386958462f114"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaymon%2Fdsnparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaymon%2Fdsnparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaymon%2Fdsnparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jaymon%2Fdsnparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jaymon","download_url":"https://codeload.github.com/Jaymon/dsnparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240987445,"owners_count":19889335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["connection","dsn","parse","python"],"created_at":"2024-10-11T09:42:36.988Z","updated_at":"2025-02-27T06:14:59.007Z","avatar_url":"https://github.com/Jaymon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dsnparse\n\nParse [dsn connection url strings](http://en.wikipedia.org/wiki/Data_source_name). Responsible for parsing dsn strings in projects like [prom](https://github.com/jaymon/prom) and [morp](https://github.com/jaymon/morp).\n\nThis is a generic version of [dj-database-url](https://github.com/kennethreitz/dj-database-url).\n\nSo, now you can create dsns like this:\n\n    scheme://user:pass@host:port/path?query=query_val#fragment\n\nFor example, let's look at a prom dsn:\n\n    prom.interface.postgres.Interface://testuser:testpw@localhost/testdb\n\nNow let's parse it:\n\n```python\nimport dsnparse\n\ndsn = \"prom.interface.postgres.Interface://testuser:testpw@localhost:1234/testdb\"\nr = dsnparse.parse(dsn)\n\nprint(r.scheme) # prom.interface.postgres.Interface\nprint(r.username) # testuser\nprint(r.password) # testpw\nprint(r.host) # localhost\nprint(r.port) # 1234\nprint(r.hostloc) # localhost:1234\nprint(r.paths) # ['testdb']\n```\n\nAlso, dsnparse can easily use environment variables:\n\n```python\nr = dsnparse.parse_environ('ENVIRONMENT_VARIABLE_NAME')\n```\n\nI tried to keep the interface very similar to [urlparse](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlparse) so it will feel familiar to use.\n\n\n## Customizing\n\nBy default, `dsnparse.parse(dsn)` returns a `ParseResult` instance, but that can be customized:\n\n```python\nimport dsnparse\n\nclass MyResult(dsnparse.ParseResult):\n    def configure(self):\n        # expose an interface property\n        self.interface = self.scheme\n\ndsn = \"Interface://testuser:testpw@localhost:1234/testdb\"\nr = dsnparse.parse(dsn, parse_class=MyResult)\nprint(isinstance(r, MyResult)) # True\nprint(r.interface) # Interface\n```\n\n\n## Install\n\nUse pip:\n\n    pip install dsnparse\n\nor use pip with github:\n\n    pip install -U \"git+https://github.com/Jaymon/dsnparse#egg=dsnparse\"\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaymon%2Fdsnparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaymon%2Fdsnparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaymon%2Fdsnparse/lists"}