1、导出csv表
from settings_Address import *
from sqlalchemy import create_engine, MetaData
import pandas as pd
def create_conn(Postgis_user,Postgis_password,Postgis_host,Postgis_port,dbname_PG):# return create_engine('Postgis+pyPostgis://{}:{}@{}:{}/{}'.format(Postgis_user,Postgis_password,Postgis_host,Postgis_port,dbname_PG))return create_engine('postgresql://{}:{}@{}:{}/{}'.format(Postgis_user,Postgis_password,Postgis_host,Postgis_port,dbname_PG))def save_csv(table_name):# 建立连接conn=create_conn(Postgis_user,Postgis_password,Postgis_host,Postgis_port,dbname_PG)query = "SELECT * FROM {}".format(table_name)df = pd.read_sql_query(query, conn)df.to_csv("./data/"+table_name+".csv", index=False)print("导出数据成功:","./data/"+table_name+".csv")if __name__ == "__main__":save_csv("smssencoding")
2、Arcgis中csv表导入gdb
3、Qgis中gdb导入postgis
直接拖过去
再导入postgis数据库中