Skip to content

Commit c34c581

Browse files
authored
Merge pull request Pennyw0rth#658 from nikaiw/fix_host_duplicate
Update database.py
2 parents e61799a + 02f4439 commit c34c581

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

nxc/protocols/smb/database.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def db_schema(db_conn):
3939
db_conn.execute(
4040
"""CREATE TABLE "hosts" (
4141
"id" integer PRIMARY KEY,
42-
"ip" text,
42+
"ip" text UNIQUE,
4343
"hostname" text,
4444
"domain" text,
4545
"os" text,
@@ -257,7 +257,7 @@ def add_host(
257257
# TODO: find a way to abstract this away to a single Upsert call
258258
q = Insert(self.HostsTable) # .returning(self.HostsTable.c.id)
259259
update_columns = {col.name: col for col in q.excluded if col.name not in "id"}
260-
q = q.on_conflict_do_update(index_elements=self.HostsTable.primary_key, set_=update_columns)
260+
q = q.on_conflict_do_update(index_elements=["ip"], set_=update_columns)
261261

262262
self.db_execute(q, hosts) # .scalar()
263263
# we only return updated IDs for now - when RETURNING clause is allowed we can return inserted

0 commit comments

Comments
 (0)