# coding=utf-8
#author:        4N
#createtime:    2020/12/23
#email:         nheweijun@sina.com
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker,Session
from sqlalchemy.engine import ResultProxy
import multiprocessing
import threading

import time

from osgeo import ogr
from osgeo.ogr import *

# session:Session = get_db_session("postgresql://postgres:chinadci@172.26.99.168:5432/postgres")
# bbox="113.2470703125 22.840576171875,113.258056640625 22.8515625"
# # table="fs1kw_vacuate_0_000075"
# table="fs900w_1"
# sql ="SELECT geom  FROM {} WHERE geom && 'BOX3D({})'::box3d limit 100000".format(table,bbox)

import base64

from kazoo.client import KazooClient

if __name__ == '__main__':


    fn = "PG: user=postgres password=chinadci host=172.26.60.101 port=5432 dbname=ceshi "
    driver = ogr.GetDriverByName("PostgreSQL")
    if driver is None:
        raise Exception("打开PostgreSQL驱动失败,可能是当前GDAL未支持PostgreSQL驱动!")
    ds :DataSource= driver.Open(fn, 1)
    if ds is None:
        raise Exception("打开数据源失败!")

    for i in range(1,13):
        tn = "t{}".format(i)
        layer : Layer = ds.GetLayerByName(tn)

        print(layer.GetGeomType())