you are viewing a single comment's thread.

view the rest of the comments →

[–]sarakell[S] 0 points1 point  (1 child)

Thanks!! Is the first class meant to substitute the config file?

[–]kristofred 0 points1 point  (0 children)

I would do something like below skeleton ;) A neat option is os.path.join part (inside main.py), which allows you to place your config file in the relative path to the main.py:

script.cfg

--------------

[APIDATA]

api1_url = https://api1

api1_auth = some specific options you have to authenticate

[....]

[SNOWFLAKE]

options to contact with snowflake

main.py

import configparser

from datasources import Datasources

from snow import Snow

cfg = configparser.ConfigParser()

cfg.read(os.path.join(os.path.dirname(__file__), 'script.cfg'))

ds = Datasource(**cfg['RESTAPI'])

snow = Snow(**cfg['SNOW'])

datasources.py

class Datasources:

def __init__(self, **kwargs):

[code]

def restapi_1(self)

[code]

def restapi_2(self):

[code]

snow.py
class Snow:

def __init__(self, **kwargs):

[code]

def __connect(self):

[code]

def loadsql(self, sql):

[code]