update needed to merge, which isn't the default action
This commit is contained in:
parent
409f8c0c01
commit
edf9bfc1f5
23
driver.py
23
driver.py
@ -17,26 +17,18 @@ async def main():
|
|||||||
ffrom = urls[0]
|
ffrom = urls[0]
|
||||||
to= urls[0]
|
to= urls[0]
|
||||||
|
|
||||||
from_id = ""
|
to_id = None
|
||||||
to_id = ""
|
from_id = None
|
||||||
|
|
||||||
|
print(ffrom, "->", to)
|
||||||
|
|
||||||
# FROM
|
# FROM
|
||||||
result = await db.query(f"SELECT id FROM website WHERE url='{ffrom}'")
|
result = await db.query(f"SELECT id FROM website WHERE url='{ffrom}'")
|
||||||
if (len(result[0]['result']) > 0):
|
if (len(result[0]['result']) > 0):
|
||||||
# The record exists
|
|
||||||
await db.update('website', {
|
|
||||||
'url':ffrom,
|
|
||||||
'crawled':True,
|
|
||||||
})
|
|
||||||
from_id = result[0]['result'][0]['id']
|
from_id = result[0]['result'][0]['id']
|
||||||
|
await db.query(f"UPDATE {from_id} MERGE {{ crawled: True }}")
|
||||||
else:
|
else:
|
||||||
from_response = await db.create(
|
from_response = await db.create("website", { "url":ffrom, "crawled":True, } )
|
||||||
"website",
|
|
||||||
{
|
|
||||||
"url":ffrom,
|
|
||||||
"crawled":True,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
from_id = from_response[0]["id"]
|
from_id = from_response[0]["id"]
|
||||||
|
|
||||||
# TO
|
# TO
|
||||||
@ -48,9 +40,6 @@ async def main():
|
|||||||
else:
|
else:
|
||||||
to_id = result[0]['result'][0]['id']
|
to_id = result[0]['result'][0]['id']
|
||||||
|
|
||||||
print("From: ", from_id)
|
|
||||||
print("To: ", to_id)
|
|
||||||
|
|
||||||
await db.query(f"RELATE {from_id} -> links_to -> {to_id}");
|
await db.query(f"RELATE {from_id} -> links_to -> {to_id}");
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user