This commit is contained in:
Bob 2019-10-18 16:01:44 +08:00
parent 04cc438323
commit 862c43e54c
3 changed files with 26 additions and 11 deletions

View File

@ -2,15 +2,14 @@ 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'
GT = 'host=210.77.68.250 port=5432 dbname=qilianshan user=qilianshan password=g214G214'
G = 'host=210.77.68.250 port=5432 dbname=sanjiangyuan user=sanjiangyuan password=g214G214'
def insert_section(code, the_geom):
def insert_section(id, atitle):
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)
sql = "insert into areas (id, atitle) values ('%s', '%s')" % (id, atitle)
print sql
cursor.execute(sql)
connection.commit()
@ -20,11 +19,12 @@ def insert_section(code, the_geom):
if __name__ == '__main__':
with psycopg2.connect(GT) as connection:
with connection.cursor() as cursor:
cursor.execute('select cmt, st_astext(geom) from observ_ponits ')
cursor.execute('select * from areas ')
results = cursor.fetchall()
for r in results:
code = r[0].upper()
the_geom = r[1]
id = r[0]
atitle = r[1]
print code, the_geom
insert_section(code, the_geom)
print id,atitle
#insert_section(id, atitle)

View File

@ -0,0 +1,15 @@
import uuid
import psycopg2
G = 'host=210.77.68.250 port=5432 dbname=sanjiangyuan user=sanjiangyuan password=g214G214'
if __name__ == '__main__':
with open("specimen_gs_matched.csv") as f:
for r in f:
print r

View File

@ -27,4 +27,4 @@ if __name__ == '__main__':
name = r[2]
print id,code, name
update_probe(id, code, name)
#update_probe(id, code, name)