Giter VIP home page Giter VIP logo

dsnparse3's Introduction

dsnparse

Build Status

Parse dsn connection url strings. I kept duplicating dsn parsing code for things like prom and morp, and I realized I was going to need many more dsn urls in the future so I decided to create something a little more modular.

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 dsnparse3

dsn = "prom.interface.postgres.Interface://testuser:testpw@localhost:1234/testdb"
r = dsnparse3.parse(dsn)

print r.scheme # prom.interface.postgres.Interface
print r.username # testuser
print r.password # testpw
print r.host # localhost
print r.hostloc # localhost:1234
print r.paths # ['testdb']

Also, dsnparse can easily use environment variables:

r = dsnparse.parse_environ('ENVIRONMENT_VARIABLE_NAME')

Install

Use pip:

pip install dsnparse3

License

MIT

dsnparse3's People

Contributors

mylokin avatar jaymon avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.