标签:rop str 用户名 try from Owner 查看 tool 作用
1、查看数据库及用户名
./psql -l
2、以oftenlin 用户登陆 postgres 数据库
./psql -d postgres -U oftenlin
3、列举表,相当于mysql的show tables
\dt
4、查看表结构,相当于desc tblname,show columns from tbname
\d tblname
5、postgresql 支持 gis 功能
CREATE EXTENSION postgis;
查看 GIS 插件是否起作用
SELECT PostGIS_Full_Version();
6、创建数据表
DROP TABLE IF EXISTS "public"."link_info";
CREATE TABLE "public"."link_info" (
"edgeid" int8 NOT NULL,
"from_node_id" int8,
"to_node_id" int8,
"two_way" int2,
"spd" float4,
"vertex_cnt" int4,
"geo" geometry
);
ALTER TABLE "public"."link_info" OWNER TO "postgres";
ALTER TABLE "public"."link_info" ADD CONSTRAINT "link_info_pkey" PRIMARY KEY ("edgeid");
7、创建空间索引
CREATE INDEX linkinfo_geom_idx ON public.link_info USING GIST (geom);
8、python 连接 PostgreSQL
使用 psycopg2 库 pip install
安装过程中出现
Error: pg_config executable not found
需要把 /Library/PostgreSQL/9.6/bin 添加到环境变量
安装成功后仍然没有办法使用,需要做动态链接库的软连接
sudo install_name_tool -change libpq.5.dylib /Library/PostgreSQL/9.6/lib/libpq.5.dylib /Users/didi/anaconda2/envs/py36/lib/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-darwin.so
sudo install_name_tool -change libssl.1.1.dylib /Library/PostgreSQL/9.6/lib/libssl.1.1.dylib /Users/didi/anaconda2/envs/py36/lib/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-darwin.so
sudo install_name_tool -change libcrypto.1.1.dylib /Library/PostgreSQL/9.6/lib/libcrypto.1.1.dylib /Users/didi/anaconda2/envs/py36/lib/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-darwin.so
标签:rop str 用户名 try from Owner 查看 tool 作用
原文地址:https://www.cnblogs.com/oftenlin/p/12244707.html