30 lines
1019 B
Python
30 lines
1019 B
Python
|
import uuid
|
||
|
|
||
|
import psycopg2
|
||
|
|
||
|
GT = 'host=210.77.68.250 port=5432 dbname=g214g214_test user=g214 password=g214G214'
|
||
|
G = 'host=210.77.68.250 port=5432 dbname=g214db user=g214 password=g214G214'
|
||
|
|
||
|
|
||
|
def insert_section(code, the_geom):
|
||
|
with psycopg2.connect(G) as connection:
|
||
|
with connection.cursor() as cursor:
|
||
|
id = uuid.uuid4()
|
||
|
sql = "insert into base_section (id, code, rtu, box, the_geom) values ('%s', '%s', false, false, st_geometryfromtext('%s', 4326))" % (id, code, the_geom)
|
||
|
print sql
|
||
|
cursor.execute(sql)
|
||
|
connection.commit()
|
||
|
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
with psycopg2.connect(GT) as connection:
|
||
|
with connection.cursor() as cursor:
|
||
|
cursor.execute('select cmt, st_astext(geom) from observ_ponits ')
|
||
|
results = cursor.fetchall()
|
||
|
for r in results:
|
||
|
code = r[0].upper()
|
||
|
the_geom = r[1]
|
||
|
|
||
|
print code, the_geom
|
||
|
insert_section(code, the_geom)
|