postgis数据库导出csv表再导入postgis

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

postgis数据库导出csv表再导入postgis_第1张图片

3、Qgis中gdb导入postgis

直接拖过去
postgis数据库导出csv表再导入postgis_第2张图片
再导入postgis数据库中
postgis数据库导出csv表再导入postgis_第3张图片

你可能感兴趣的:(MySQL,postgresq,MongoDB,Redis,数据库)