海量数据COPY到postgresql
将存有海量的文件如 fund_hq_history.csv文件数据导入postgresql的相应表中:
COPY fund_hq_history (id, fund_code, wan_nav, trans_date, is_monetary_fund, date_created, last_updated)
FROM '/Users/liumj/my_files/table_one.csv' delimiter as’,’ NULL AS '';
(用pwd查看文件的具体位置)
1、如果报 read permission denied,可能是该文件所在文件夹和该文件没有对外开放相关权限
chmod a+rwx ~/my_files
chmod a+rwx ~/my_files/table_one.csv
从一张表里查到的数据插入到另一个张表
insert into fud_product(date_created, last_updated, product_no, product_name, product_type, product_status, product_ext_json, order_level, show_type)
select now(),now(),fund_code,fund_name,'1','1','',0,'NORMAL' from fud_fund_product where show_status!='0';
UPDATE fud_product SET product_name_piyin = ft.all_pin_yin,initial_pin_yin=ft.initial_pin_yin FROM fud_fund_filter as ft WHERE ft.fund_code = product_no;
update fud_product set product_tags='["稳健型"]' from fud_fund_product as pro where product_no=pro.fund_code and pro.risk_level='0';
安装好charles后,在Help中注册,然后在Help—SSL Proxying—点击 ….or remote brower
手机连接无线网络,设置代理,地址填写上一步出现的IP,然后在手机浏览器中,输入上一步中提示的 chls.pro/ssl 在手机里安装证书,中途需要再电脑上点击allow
手机证书安装完成后,就可以用charles抓https的包了,对于https的请求,需要在charles上右键 enable ssl proxying ,如此,请求的https就可以看到相关抓包数据了
ITerm2 用profile配置直接连接服务器
创建文件 ~/.ssh/autossh.exp 内容如下
#!/usr/bin/expect
#verion:1.2
#author:liumj
#modifed:2017-01-01
set timeout 60
set host [lindex $argv 0]
set port [lindex $argv 1]
set username [lindex $argv 2]
set passwd [lindex $argv 3]
spawn ssh -p $port $username@$host
if {$argc==4} {
expect {
"(yes/no)?" {
send "yes\n"
expect "Password:"
send "$passwd\n"
}
"assword:" {
send "$passwd\n"
}
"password:" {
send "$passwd\n"
}
}
}
interact
赋予可执行权限
chmod +x ~/.ssh/autossh.exp
然后ITerm2—Preferences, 选择Profiles, 新建一个Profile Name, 右边: Basics中取个名字, Command中选择 Command, 输入内容如下
~/.ssh/autossh.exp 10.0.9.119 22 name password // IP Port Username Password
如此,打开ITerm2后,按 CMD O 就可以选择配置的服务器连接,不用再输入地址和密码啦