跳到主要內容

發表文章

[Python] Flask web in Docker- using pyodbc

 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"
最近的文章

[python] 讀取csv to pandas(解決字串用雙引號出錯)

  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)

[python] python egg package

python egg       1. install egg packages   python setup.py  bdist_egg   *add directors - project_directoty   - dist   -build           2. project files        *files  archietacture   - project_directoty   -setup.py   - module_name   --__init__.py   --demo.py           ###setup.py###       from  setuptools  import setup,  find_packages       setup(       name=" project_name ",       version="0.1",       packages= find_packages (),        zip_safe =False,           description="demo egg",        long_description ="demo egg.",       author="una",        author_email="unachou@gmail.com ",           license="GPL",       # keywords =( "test", "egg"),       platforms=" Independant ",        url ="",       )