g214/data_import/import_section_for_road.py

30 lines
876 B
Python

import uuid
import psycopg2
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(id, atitle):
with psycopg2.connect(G) as connection:
with connection.cursor() as cursor:
sql = "insert into areas (id, atitle) values ('%s', '%s')" % (id, atitle)
print sql
cursor.execute(sql)
connection.commit()
if __name__ == '__main__':
with psycopg2.connect(GT) as connection:
with connection.cursor() as cursor:
cursor.execute('select * from areas ')
results = cursor.fetchall()
for r in results:
id = r[0]
atitle = r[1]
print id,atitle
#insert_section(id, atitle)