Blog Cover Image

Inspire you to have New thinking, Walk out your unique Road.

後端小菜鳥學習記錄(3)

Posted on Sep 17, 2018

9/14

帶了之前自己買的 Introducing Python 書(早 10~早 11:30)

配合網頁,早上學習

資料的輸出輸入, JSON,SQLAlchemy



一週統計

9/10

Begin(1.5h)

開始學習(3h)

Anaconda, mongoDB, **flask**

--

利用 SQLAlchemy/Pymysql 兩種方法扔資料上資料庫/ 10 秒內完成 4000 筆資料傳輸

架設 MySQL/打通任督二脈(3h)

學習用終端機連 MySQL

--

9/11

搞懂任務內容/搞懂 Mysql 指令/搞懂 Pymysql/SQLAlchemy(早上 2.5h)

**學著操作 Mysql **

STUDY: 任何丟資料方法

SQLAlchemy, Pymysql, Flask+SQLAlchemy

確認連結資料庫

新建測試資料/扔資料上去 MySQL(1.5h)(pymysql)

搞懂 python3 及 mysql 版本問題的指令不同

用兩種方法上傳(寫到 7 點)

成就達成: Flask+Pymysql / Flask + SQLAlchemy(尚未解決)

--

9/12

看“資料視覺化,使用 python 與 js”書 p313 始 / Review 昨日練習的程式(早上 2h)

Flask, flask-sqlalchemy,pymsql

**Try flask-SQLAlchemy in local db(30min)(Complete): **

To test Flask-sqlalchemy can work to local db (先測試在 local 可否使用 sqlalchemy 寫入資料)

順利利用 flask-SQLAlchemy input data to mysql (從 9/11 下午 4 點-9/12 下午) (約 5h)

--

將固定資料改為 GET/POST 接受參數 >> 上傳至資料庫(9/12 15:37 始)

flask-requests, postman, get,post

STUDY Flask Request /POST,查詢資料時間(約 3 個小時/午 4:00~晚 7:00)

--

9/13

利用 post 方式接收參數,融合 SQLAlchemy 上傳資料進 Mysql(5 小時/早 10~下午 3:30)

Debug 技巧, ngrep, Try, Except, BaseException, postman

將 ErrorInfo 及 TestLogInfo 動態傳送/固定值傳送 Pymysql & SQLAlchemy 寫完+整合成一個檔案(1 小時 20 分 ~午 5:20)

總結為,花費最多時間:Debug + 觀念釐清

總共花 10 小時在 STUDY

總共花 22 小時在 CODING



學把自己的 Code 寫上 GitLab(早 11:30 始)

Docker / GitLab

https://www.docker.com/

https://gitlab.com/

GIT

git clone https://________________________________________

git branch

https://git-scm.com/book/zh-tw/v1/Git-%E5%88%86%E6%94%AF-%E9%81%A0%E7%AB%AF%E5%88%86%E6%94%AF

https://backlog.com/git-tutorial/tw/stepup/stepup2_2.html

git push

DOCKER

#frontground runserver
docker-compose up 

#background in server runserver
docker-compose up -d

#close sever
docker-compose down

#list up server status list
docker-compose ps

#查詢指令
docker-compose




curl

https://www.daniellittle.xyz/curl-to-postman/

DockerFile (所有要安裝的環境都會設在這)

nginx > > 啟動 wsgi  >> python module

新增內部socket 程式碼 nginx/project_name.conf

新增 uwsgi_name.ini
新增內部程式碼 docker-compose.yaml

剛放新的.py 檔上三個檔案都要改

set communication of nginx and wsgi

/orm/ >> wsgi, yml

LINUX

http://nersp.nerdc.ufl.edu/~dicke3/nerspcs/ls.html

man ls
$man ___
手冊

#vim內查詢 -G是指令
/? -G

SSH

直接定義 ssh,不用打一串

$mkdir .ssh
$vi .ssh/config




Host ssh-easy-name
Hostname ip
User usr




$sh rsync.sh
用ssh上傳檔案至server

$ssh ssh-easy-name

pw _(server 密碼)


練習將新的.py 檔放在 local docker,並且用 git 建立分支上傳至 GitLab

$git clone _______________________

於 project 新建一個分支

$git branch [branch-name]

$git checkout [branch-name]

將新的 new.py 檔放進去 project

$git add new.py

更改 docker 三個檔

新增內部socket 程式碼 nginx/project_name.conf
新增 uwsgi_name.ini
新增內部程式碼 docker-compose.yaml
.config >> uwsgi.ini >> .py




$docker-compose build
$docker-compose up




$git commit -m "add b.txt"
$git add _______




grep 'projectname.sock'
uwsgi.ini:socket=/tmp/projectname.sock




$sh rsync.sh
用ssh上傳檔案至server

$git push

https://gitbook.tw/chapters/using-git/amend-commit1.html

https://kaochenlong.com/2017/09/19/learn-git-for-your-own-good/

http://linux.vbird.org/linux_basic/0340bashshell-scripts.php#script_why

http://blog.xuite.net/tolarku/blog/65150577-%5BCentOS%5D+cp%E3%80%81scp%E3%80%81rsync+%E8%B3%87%E6%96%99%E5%82%99%E4%BB%BD%E6%A9%9F%E5%88%B6

測試工具: Jmeter

https://jmeter.apache.org/download_jmeter.cgi

https://kingofamani.gitbooks.io/git-teach/content/chapter_2/repo.html


https://columns.chicken-house.net/2016/09/15/microservice-case-study-01/

bottle: python

https://bottlepy.org/docs/dev/