Python flask web run by Docker *using ODBC: The server need to install ODBC driver microsoft install odbc Copy odbcinst.ini to container COPY odbcinst.ini /etc/odbcinst.ini The docker need to install odbc before pip install pyodbc RUN apt-get update && apt-get install -y --no-install-recommends \ unixodbc-dev \ unixodbc \ libpq-dev vim odbcinst.ini , check odbc driver path, then run image setting volumn path docker run -v /opt/microsoft/:/opt/microsoft/ -p 5000:5000 ProjectName -Dockerfile: FROM python:3.7-rc RUN apt-get update && apt-get install -y --no-install-recommends \ unixodbc-dev \ unixodbc \ libpq-dev COPY odbcinst.ini /etc/odbcinst.ini RUN mkdir /TargetPath COPY ./Project /TargetPath # set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # set work directory WORKDIR /TargetPath # install dependencies RUN pip install --upgrade pip RUN pip install -r requirements.txt CMD [ "python"
def read_string_io_csv(file_name, headers): with open(file_name, encoding="utf8") as csvfile: csv_reader = csv.reader(csvfile, delimiter=',', quotechar='"', skipinitialspace=True, doublequote=False, quoting=csv.QUOTE_ALL, escapechar='\\') line_count = 0 data = [] num_of_col = len(headers) for row in csv_reader: data_row = {} for col in range(num_of_col): data_row[headers[col]] = row[col] data.append(data_row) line_count += 1 return pd.DataFrame(data)