gegeben:
- Windows Server2016
- Python 3.7.4
- configparser per pip installiert
*.cfg:
Code: Alles auswählen
[DEFAULT]
driver = {SQL SERVER}
server = ip-Adresse
database = DB
Trusted_Connection = yes
Auszug aus dem Script *.py:
[code]
import configparser
CONFIG_FILE_PATH = '\\Server\c$\scripts'
CONFIG_FILE = os.path.join(CONFIG_FILE_PATH, '*.cfg')
config = configparser.ConfigParser()
config.read(CONFIG_FILE)
server = config.get('DEFAULT', 'server')
database = config.get('DEFAULT', 'database')
PS C:\scripts> & "C:/Program Files/Python37/python.exe" c:/scripts/F1_log_to_sql_win_esi1.py
c:/scripts/F1_log_to_sql_win_esi1.py:21: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
import pymssql
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\configparser.py", line 788, in get
value = d[option]
File "C:\Program Files\Python37\lib\collections\__init__.py", line 916, in __getitem__
return self.__missing__(key) # support subclasses that define __missing__
File "C:\Program Files\Python37\lib\collections\__init__.py", line 908, in __missing__
raise KeyError(key)
KeyError: 'server'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:/scripts/F1_log_to_sql_win_esi1.py", line 38, in <module>
server = config.get('DEFAULT', 'server')
File "C:\Program Files\Python37\lib\configparser.py", line 791, in get
raise NoOptionError(option, section)
configparser.NoOptionError: No option 'server' in section: 'DEFAULT'[/code]
Das Script hatte unter Linux und auf einem w10 Rechner funktioniert.
Jetzt auf dem Server gibt es die Fehlermeldung.
Was übersehe ich hier bzw. wo muss ich nachschauen um die Funktion hinzubekommen?
Danke schon mal im Voraus