Skip to main content

Store property in database, like pyjavaproperties(Property JAVA)

Project description

pydbproperties 0.3
==============
With this script, you can use store properties into a
MySQL table, you can change the name of the table, and
list the properties into a output stream or file
stream, etc.

Right now it only works with MySQL Database, I will be
working in other databases.

Dependencies:
=============
MySQL-python (1.2.3)
MysqlSimpleQueryBuilder (0.2.8)

Installation:
=============
MySQL-python has issues when installing by pip
you can install it with your package manage of
your distribution

ubuntu: sudo apt-get install python2.7-mysqldb
Centos/RHEL/Fedora: yum install MySQL-python

Once MySQL-python is installed, you can install
MysqlSimpleQueryBuilder:

pip install MysqlSimpleQueryBuilder

And now you are ready to install pydbproperties:

pip install pydbproperties

Example:
========
from pydbproperties import pydbproperties
prop = pydbproperties()
prop.set_table_name('my_table')
for b in range(5):
prop.set_property('key' + str(b), 'value' + str(b))

config = {
"host": 'localhost',
"user": 'root',
"passwd": '',
"db": 'test_pydbproperties',
}
prop.conn(**config)
# prop.load()
prop.list()
prop.set_property('key_test', 'value_test')
prop.store()
prop.list()

======================
Output:
-- listing properties --
key3=value3
key2=value2
key1=value1
key0=value0
key4=value4
-- listing properties --
key3=value3
key2=value2
key1=value1
key0=value0
key4=value4
key_test=value_test

=====================
Table in MySQL:

MariaDB [test_pydbproperties]> use test_pydbproperties
Database changed
MariaDB [test_pydbproperties]> show tables;
+-------------------------------+
| Tables_in_test_pydbproperties |
+-------------------------------+
| my_table |
+-------------------------------+
1 row in set (0.00 sec)

MariaDB [test_pydbproperties]> select * from my_table;
+----------+------------+
| key | value |
+----------+------------+
| key0 | value0 |
| key1 | value1 |
| key2 | value2 |
| key3 | value3 |
| key4 | value4 |
| key_test | value_test |
+----------+------------+
6 rows in set (0.00 sec)

Project details


Download files

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

Source Distribution

pydbproperties-0.3.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

pydbproperties-0.3-py2.7.egg (11.2 kB view details)

Uploaded Egg

File details

Details for the file pydbproperties-0.3.tar.gz.

File metadata

  • Download URL: pydbproperties-0.3.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pydbproperties-0.3.tar.gz
Algorithm Hash digest
SHA256 7fb1372864f37d6d7e8f900c87d8695f2c510c0f9fbdae3baf991fe2b365a019
MD5 56cc9aaac0a79d77c93607f9e232d9b7
BLAKE2b-256 c82edc89a709e474877614e506d85deabb05375a1424bbdff6861171d72687b2

See more details on using hashes here.

File details

Details for the file pydbproperties-0.3-py2.7.egg.

File metadata

File hashes

Hashes for pydbproperties-0.3-py2.7.egg
Algorithm Hash digest
SHA256 12ce90427d539779f694df37b5efb7e155b228e1974b60d419832adaeeade8ca
MD5 2d00517168d53ab3f6320089df0b9c8b
BLAKE2b-256 c7d135a0350e7b96a3d053b221d6d6176c4df6012191c935e24ba44c6226d4d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page