0

i could not find seemingly similarly already posted in stack so here goes a short example:

# Current Code
dbCon = pyodbc.connect(sCon, autocommit=True)

# Future/Desired pseudo code
vAutocommit = {'autocommit': True}
dbCon = pyodbc.connect(sCon, vAutocommit)

I'm sure i'm missing a simple python concept so please forgive to being newer to this language. Thank you.

Tim Wiley
  • 229
  • 2
  • 8
  • 1
    Possible duplicate of [Passing a dictionary to a function as keyword parameters](https://stackoverflow.com/questions/334655/passing-a-dictionary-to-a-function-as-keyword-parameters) – glibdud Apr 17 '19 at 13:34

1 Answers1

1

You can pass the dictionary and unpack it as a kwarg:

# Current Code
dbCon = pyodbc.connect(sCon, autocommit=True)

# Future/Desired pseudo code
vAutocommit = {'autocommit': True}
dbCon = pyodbc.connect(sCon, **vAutocommit) <<< the ** unpacks the
                                                dictionary's key/value
                                                pairs as arguments.
Nordle
  • 2,915
  • 3
  • 16
  • 34