跳到主要內容

發表文章

Linux pyodbc driver not found error

Linux pyodbc driver not found error enviroment Linux Ubuntu python3        == execute ===       [python] import  pyodbc   conn =  pyodbc.connect ('Driver={ODBC Driver 17 for SQL Server}... )       == error ===   file not found (0) ( sqldriverconnect )  pyodbc  ......         == solved ===   vim / etc /odbcinst.ini   [ODBC Driver 17 for SQL Server]   Description=Microsoft ODBC Driver 17 for SQL Server   Driver=/opt/ microsoft /msodbcsql17/lib64/libmsodbcsql-17.4.so.2.1   UsageCount =1  

[python] Django connect to Mysql setting

作業環境 mac os python3.7  安裝mysql  brew update brew install MySQL  pip install -r requirements.txt requirements.txt 包含以下 mysqlclient Django==2.1.4 pymysql 建立 app (Directory) python manage.py startapp app_name 編輯 settings.py ...... ...... DATABASES = {     'default': {         'ENGINE': 'django.db.backends.mysql',         'NAME': 'DbName',         'USER': 'user',         'PASSWORD': 'password',         'HOST': '127.0.0.1',         'PORT': '3306',     } } ...... ...... Django 連結到已有Table的DB 建立model.py python manage.py inspectdb > app_name /models.py python manage.py inspectdb 直接複製後貼上到model.py 文件 建立migrations資料表 python manage.py makemigrations migrations 同步資料表 python manage.py migrate app_name 參考文件 Django連結現有MySQL資料庫 https://docs.djangoproject.com/en/2.2/ref/da...

[python] python 時區轉換 ( timezone )

python 時區轉換 import datetime as dt import pytz d = dt.datetime(2019,1,1,14,0,0) #create Taipei timezone tw = pytz.timezone('Asia/Taipei') #set d timezone is 'Asia/Taipei' twdt = tw.localize(d) #change to utc time utc_dt = twdt.astimezone(pytz.utc) *注意 網路上很多使用 d.replace(tzinfo=tw)   但是可能會出現時差問題, 如下: datetime.time(23, 18, 5, tzinfo=<DstTzInfo 'Asia/Shanghai' LMT+8:06:00 STD>) 參考文件 python时区设置——pytz模块

[Linux] 解決 unix ///tmp/supervisor.sock no such file

supercisor run  一段時間系統會自動刪除tmp內的檔案, 這時候就會出現以下問題: unix ///tmp/supervisor.sock no such file 作業環境: Centos 7 *解決方法 修改 supervisor 設定檔 [...]#  vim /etc/supervisor/supervisord.conf [unix_http_server] file= /var/run/ supervisor.sock  ... [supervisord] logfile= /var/log/ supervisord.log ... [supervisorctl] serverurl=unix:/// var/run/ supervisor.sock 重新執行supervisor  關閉supervisor相關進程 [...]#  ps -ef | grep supervisord   [...]#  kill (進程id) 重新執行supervisor [...]# supervisord or [...]# supervisord -c /etc/supervisor/supervisord.conf 參考連結 解决unix:///tmp/supervisor.sock no such file的问题

[GCP] gcloud command

登入GCP  - 開發專案如果權限沒有另外設定,依預設登入的google專案 ( Google Cloud SDK Shell ) ---2018/08/30 updated--- gcloud auth login gcloud auth application-default login gcloud config set project  {projId} big query 設定  Partition expiration bq update --time_partitioning_expiration [INTEGER] [PROJECT_ID]:[DATASET].[TABLE] [INTEGER]: second