2018-07-21 18:28:31 +00:00
|
|
|
import configparser
|
|
|
|
|
|
|
|
def read_config():
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config.read('GeoffreyConfig.ini')
|
|
|
|
|
|
|
|
if len(config.sections()) == 0:
|
|
|
|
create_config(config)
|
|
|
|
print("GeoffreyConfig.ini generated.")
|
|
|
|
quit(0)
|
|
|
|
|
|
|
|
return config
|
|
|
|
|
|
|
|
|
|
|
|
def create_config(config):
|
|
|
|
config['Discord'] = {'Token': ''}
|
|
|
|
config['SQL'] = {'Dialect+Driver': '', 'username': '', 'password':'', 'host': '', 'port': '', 'database':'',
|
|
|
|
'test_args':''}
|
|
|
|
|
|
|
|
with open('GeoffreyConfig.ini', 'w') as configfile:
|
|
|
|
config.write(configfile)
|
|
|
|
|
|
|
|
|
|
|
|
def get_engine_arg(config):
|
|
|
|
driver = config['SQL']['Dialect+Driver']
|
|
|
|
username = config['SQL']['username']
|
|
|
|
password = config['SQL']['password']
|
|
|
|
host = config['SQL']['host']
|
|
|
|
port = config['SQL']['port']
|
|
|
|
database_name = config['SQL']['database']
|
|
|
|
|
2018-07-21 19:47:40 +00:00
|
|
|
engine_args = '{}://{}:{}@{}:{}/{}?charset=utf8mb4&use_unicode=1'
|
2018-07-21 18:28:31 +00:00
|
|
|
|
|
|
|
return engine_args.format(driver, username, password, host, port, database_name)
|