Class 7
A configuration file consists of sections, each led by a [section] header, followed by key/value entries separated by a specific string.
[DEFAULT]
ServerAliveInterval = 45
Compression = yes
CompressionLevel = 9
ForwardX11 = yes
[bitbucket.org]
User = hg
[topsecret.server.com]
Port = 50022
ForwardX11 = no
import configparser
#Load Credentials
config = configparser.ConfigParser()
config.sections()
config.read('Credentials.ini')
config.sections()
import mysql.connector
# Database
dbconfig = {
'database': database,
'user': user,
'password': password,
'host': host
}
# Conect to database
connection = mysql.connector.connect(**dbconfig)
#Consult query
df = pd.read_sql(sql, con=connection)
See Example
import json
file_name = 'json_example.txt'
myfile = open(file_name, 'r')
json_example = myfile.read()
my_dict = json.loads(json_example)