postgresql_action
SELECT *
FROM x123_area a
LEFT JOIN x123_user_task_brief utb ON utb.ref_area_code = a.area_code WHERE area_name
LIKE '福田星河%' OR area_name LIKE '%佳莲%'
sudo -u postgres createuser --superuser dbuser
sudo -u postgres psql
w
ubuntu@VM---ubuntu:/etc/init.d$ sudo -u postgres createuser --superuser dbuser
ubuntu@VM---ubuntu:/etc/init.d$ sudo -u postgres psql
psql (9.5.)
Type "help" for help. postgres=# show databases
postgres-# create database wdb
postgres-# show databases
postgres-# ;
ERROR: syntax error at or near "create"
LINE : create database wdb
^
postgres=# show databases;
ERROR: unrecognized configuration parameter "databases"
postgres=# create table wtb
postgres-# w int,
postgres-# wb smallint);
ERROR: syntax error at or near "w"
LINE : w int,
^
postgres=# create table wtb
(w int,
wb smallint);
CREATE TABLE
postgres=# insert into wtb values (,);
INSERT
postgres=# select * from wtb;
w | wb
----+----
|
( row) postgres=#
apt install postgresql
ubuntu@VM---ubuntu:~/postgresql$ pip install psycopg2
Collecting psycopg2
Downloading psycopg2-2.7.-cp27-cp27mu-manylinux1_x86_64.whl (.7MB)
% |################################| .7MB 112kB/s
Installing collected packages: psycopg2
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line , in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line , in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line , in install
**kwargs
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line , in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line , in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line , in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line , in clobber
ensure_dir(destdir)
File "/usr/local/lib/python2.7/dist-packages/pip/utils/__init__.py", line , in ensure_dir
os.makedirs(path)
File "/usr/lib/python2.7/os.py", line , in makedirs
mkdir(name, mode)
OSError: [Errno ] Permission denied: '/usr/local/lib/python2.7/dist-packages/psycopg2-2.7.1.dist-info'
ubuntu@VM---ubuntu:~/postgresql$ sudo pip install psycopg2
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting psycopg2
Retrying (Retry(total=, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f8f0915ab90>, 'Connection to pypi.python.org timed out. (connect timeout=)')': /simple/psycopg2/
Downloading psycopg2-2.7.-cp27-cp27mu-manylinux1_x86_64.whl (.7MB)
% |################################| .7MB 178kB/s
Installing collected packages: psycopg2
Successfully installed psycopg2-2.7.
ubuntu@VM---ubuntu:~/postgresql$
SELECT COUNT(1) FROM questionable_mac; SELECT detail_data->'wifi_list'->3 FROM questionable_mac; SELECT * FROM (
SELECT detail_data->>'wifi_list' AS mac_list FROM questionable_mac) AS tmp WHERE mac_list LIKE '%zzzzzz%'; CREATE TABLE control_group_1200k
(
oid_timestamp VARCHAR(64) NOT NULL PRIMARY KEY,
detail_data VARCHAR(1024)
); DROP TABLE questionable_mac ;
CREATE TABLE questionable_mac
(
mac CHAR(17) NOT NULL PRIMARY KEY,
detail_data JSON,
tbl_cp_signal_wifi_id_list VARCHAR(10240)
);
SELECT pdata
FROM ( SELECT
detail_data -> 'data' AS pdata,
detail_data -> 'data' ->> 'timestamp' AS ptimestamp
FROM apiv2_single_mac_with_res) tmp ORDER BY ptimestamp DESC
LIMIT 200;
CODE
$ awk '{c++} END {print c}' *6.csv SELECT COUNT(1)
FROM control_group_with_compute_res;
SELECT COUNT(1)
FROM (
SELECT
detail_data ->> 'city' AS pcity
FROM control_group_with_compute_res
) tmp
WHERE pcity = '深圳市' SELECT COUNT(1)
FROM (
SELECT
detail_data ->> 'city' AS pcity,
mac_with_final_res
FROM control_group_with_compute_res
) tmp
WHERE pcity = '深圳市'
AND mac_with_final_res IS NOT NULL
SELECT COUNT(1)
FROM questionable_mac
WHERE ref_region_id_num > 1; SELECT COUNT(1)
FROM (
SELECT
detail_data ->> 'city' AS pcity,
filter_regionmac_list
FROM control_group_with_compute_res
) tmp
WHERE pcity = '深圳市'
AND filter_regionmac_list IS NOT NULL;
SELECT COUNT(DISTINCT CONCAT(mac_with_final_res)),COUNT(1)
FROM (
SELECT
oid_timestamp,
detail_data ->> 'city' AS pcity,
mac_with_final_res
FROM control_group_with_compute_res
) tmp
WHERE pcity = '深圳市'
AND mac_with_final_res IS NOT NULL ;
创建视图 CREATE
VIEW
类型转换 CAST
DROP VIEW IF EXISTS v_cmp_original_vs_mac;
CREATE VIEW v_cmp_original_vs_mac AS
SELECT CAST(cmp_original_vs_mac -> '500' ->> 'dis' AS FLOAT) AS dis_f
FROM control_group_with_compute_res
WHERE cmp_original_vs_mac IS NOT NULL;
SELECT COUNT(1)
FROM v_cmp_original_vs_mac
WHERE dis_f < 0.5
UNION ALL
SELECT COUNT(1)
FROM v_cmp_original_vs_mac
WHERE dis_f >= 0.5 AND dis_f < 1
UNION ALL
SELECT COUNT(1)
FROM v_cmp_original_vs_mac;
子集 全集 计数 单行显示
SELECT
COUNT(tb_whole.f),
COUNT(tb_sub.f)
FROM tb tb_whole
LEFT JOIN (SELECT f
FROM tb
WHERE f > 10) tb_sub
ON tb_whole.f = tb_sub.f; SELECT
COUNT(tb_whole.oid_timestamp),
COUNT(tb_subset.oid_timestamp)
FROM control_group_with_compute_res tb_whole
LEFT JOIN (SELECT oid_timestamp
FROM control_group_with_compute_res
WHERE detail_data ->> 'city' = '深圳市') tb_subset
ON tb_whole.oid_timestamp = tb_subset.oid_timestamp; SELECT
COUNT(tb_whole.oid_timestamp),
COUNT(DISTINCT tb_subset.oid_timestamp)
FROM control_group_with_compute_res tb_whole
LEFT JOIN (SELECT oid_timestamp
FROM control_group_with_compute_res
WHERE detail_data ->> 'city' = '深圳市') tb_subset
ON tb_whole.oid_timestamp = tb_subset.oid_timestamp;
postgresql_action的更多相关文章
随机推荐
- Python 入门之 递归
Python 入门之 递归 1.递归: 递:一直传参 归:返回 (1)不断调用自己本身(无效递归 -- 死递归) def func(): print(1) func() func() (2)有明确的终 ...
- HNUSTOJ 1516:Loky的烦恼
1516: Loky的烦恼 时间限制: 1 Sec 内存限制: 128 MB 提交: 242 解决: 66 [提交][状态][讨论版] 题目描述 loky喜欢上一个女孩,女孩在loky眼中绝对是1 ...
- 异步Promise及Async/Await可能最完整入门攻略
此文只介绍Async/Await与Promise基础知识与实际用到注意的问题,将通过很多代码实例进行说明,两个实例代码是setDelay和setDelaySecond. tips:本文系原创转自我的博 ...
- vue-sticky组件详解
sticky简介 sticky的本意是粘的,粘性的,使用其进行的布局被称为粘性布局. sticky是position属性新推出的值,属于CSS3的新特性,常用与实现吸附效果. 设置了sticky布局的 ...
- html5移动端Meta的设置
强制让文档的宽度与设备的宽度保持1:1,并且文档最大的宽度比例是1.0,且不允许用户点击屏幕放大浏览 1 <meta name="viewport" content=&quo ...
- SpringBoot自定义配置步骤
1. 在yml中填写自定义配置 ly: sms: accessKeyId: # 短信配置 accessKeySecret: signName: xx商城 # 签名名称 verifyCodeTempla ...
- Ubuntu16.04 php7.1安装redis扩展
sudo apt install php7.1-redis //修改php配置 vi /etc/php.ini 添加extension=redis.so
- drop,delete,truncate 的区别
(1)DELETE语句执行删除的过程是每次从表中删除一行,并且同时将该行的删除操作作为事务记录在日志中保存以便进行进行回滚操作. TRUNCATE TABLE 则一次性地从表中删除所有的数据并不把单独 ...
- Docker学习笔记--传送门(持续更新)
1.ubuntu下安装docker: https://www.cnblogs.com/salmonLeeson/p/11609699.html 2.为docker配置国内镜像加速器:https:// ...
- fpga错误总结
Error (10200): Verilog HDL Conditional Statement error at ps2_con_cmd.v(11): cannot match operand(s) ...