Comparar commits
No hay commits en común. 'd939c260f0b90fc14f2cb6bd79a27c78ee83d88e' y '4f5718ef033ca7387e465e25e943d9db2774dfa9' tienen historias completamente diferentes.
d939c260f0
...
4f5718ef03
S'han modificat 1 arxius amb 30 adicions i 0 eliminacions
30
peers.py
30
peers.py
|
@ -499,6 +499,36 @@ class Peers:
|
|||
print(f'{file_path} Missing parameter {parameter}')
|
||||
sys.exit(0)
|
||||
|
||||
def write_server(server, federated_with):
|
||||
|
||||
insert_sql = "INSERT INTO world(server, federated_with, updated_at, saved_at, checked) VALUES(%s,%s,%s,%s,%s) ON CONFLICT DO NOTHING"
|
||||
|
||||
conn = None
|
||||
|
||||
try:
|
||||
|
||||
conn = psycopg2.connect(database = fediverse_db, user = fediverse_db_user, password = "", host = "/var/run/postgresql", port = "5432")
|
||||
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute(insert_sql, (server, federated_with, now, now, 'f'))
|
||||
|
||||
print(f'writing {server} to world database')
|
||||
|
||||
conn.commit()
|
||||
|
||||
cur.close()
|
||||
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
|
||||
print(error)
|
||||
|
||||
finally:
|
||||
|
||||
if conn is not None:
|
||||
|
||||
conn.close()
|
||||
|
||||
###############################################################################
|
||||
# main
|
||||
|
||||
|
|
Loading…
Referencia en una nova incidència