g214/data_import/update_base_probe.py

31 lines
935 B
Python
Raw Normal View History

2018-09-05 08:01:23 +00:00
import uuid
import psycopg2
GT = 'host=221.207.32.75 port=5432 dbname=g214 user=g214 password=g214G214'
G = 'host=210.77.68.250 port=5432 dbname=g214db2 user=g214 password=g214G214'
def update_probe(id, code, name):
with psycopg2.connect(GT) as connection:
with connection.cursor() as cursor:
sql = "update base_probe set code = '%s', name = '%s' where id = '%s'" % (code, name, id)
print sql
cursor.execute(sql)
connection.commit()
if __name__ == '__main__':
with psycopg2.connect(G) as connection:
with connection.cursor() as cursor:
cursor.execute(
"select id, code, name from base_probe ")
results = cursor.fetchall()
for r in results:
id = r[0]
code = r[1]
name = r[2]
print id,code, name
2019-10-18 08:01:44 +00:00
#update_probe(id, code, name)