-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_config.py
More file actions
27 lines (23 loc) · 1013 Bytes
/
Copy pathcreate_config.py
File metadata and controls
27 lines (23 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import ConfigParser
class CreateConfig:
def __init__(self, path):
self.path = path
def create_config(self):
self.__config = ConfigParser.ConfigParser()
self.__config.add_section('db_connection1')
self.__config.set('db_connection1', 'db_host', '127.0.0.1')
self.__config.set('db_connection1', 'db_user', 'writer')
self.__config.set('db_connection1', 'passwd', 'writer')
self.__config.set('db_connection1', 'db1', 'python4eg')
self.__config.add_section('db_connection2')
self.__config.set('db_connection1', 'db_host', '127.0.0.1')
self.__config.set('db_connection1', 'db_user', 'reader')
self.__config.set('db_connection1', 'passwd', 'reader')
self.__config.set('db_connection1', 'db1', 'python4eg')
self.__configfile = open(self.path, 'wb')
self.__config.write(self.__configfile)
def main():
conf = CreateConfig('db_config.conf')
conf.create_config()
if __name__ == '__main__':
main()