12345678910111213141516171819202122232425262728293031 |
- # 连接数据库
- import psycopg2
- from psycopg2.extras import DictCursor
- import logging
- # 配置日志
- logging.basicConfig(level=logging.INFO)
- logger = logging.getLogger(__name__)
- conn = psycopg2.connect(
- dbname="real3d",
- user="postgres",
- password="postgis",
- host="192.168.1.177",
- port="5432"
- )
- def getDiffEwkt():
- with conn.cursor(cursor_factory=DictCursor) as cur:
- sql = f"""SELECT * FROM base."t_fzss_fzxz" limit 1;"""
- complete_sql = cur.mogrify(sql, ).decode('utf-8')
- logger.info(f"Executing SQL: {complete_sql}")
- cur.execute(sql, )
- res = cur.fetchone()
- print(res)
- return res[0]
- getDiffEwkt()
|