31 lines
934 B
Python
31 lines
934 B
Python
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
|
|
update_probe(id, code, name)
|