Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Tool to handle connection strings

Project description

Travis-CI badge Read the Docs

pyconstring

Tool to handle connection strings. Offers an easy API that parses and constructs connection strings in the form of Key=Value;, as easy as handling a dictionary. Works with both Python 2.7 and 3.x

License

MIT. See License File.

Install

pyconstring is on PyPI

pip install pyconstring

or

easy_install pyconstring

Usage examples

Constructing a connection string from scratch:

>>> from pyconstring import ConnectionString
>>> cs = ConnectionString()
>>> cs['user'] = 'manuel'
>>> cs['password'] = '1234'
>>> print cs.get_string()
User=manuel;Password=1234;

Parsing an already existing string:

>>> cs = ConnectionString.from_string('key1=value1;key2=value2;')
>>> cs['key1'] = 'another value'
>>> cs.get_string()
u'Key1=another value;Key2=value2;'
>>> cs['user'] = 'johnny'
>>> print cs.get_string()
Key1=another value;Key2=value2;User=johnny;

Automated escaping when necessary:

>>> cs = ConnectionString()
>>> cs['weird=key'] = '" weird;value  '
>>> print cs.get_string()
Weird==Key='" weird;value  ';

Key translation:

>>> cs['key'] = 'value'
>>> cs.translate({'key': 'clave'})
>>> print cs.get_string()
Clave=value;

More information in the documentation.

If you find any bug or have any suggestion, feel free to send me an email or open an issue on github.

Project details


Release history Release notifications

This version
History Node

1.0.0

History Node

0.5.0

History Node

0.4.0

History Node

0.3.2

History Node

0.3.1

History Node

0.3.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pyconstring-1.0.0-py2.py3-none-any.whl (6.4 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Mar 29, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page