J
J
jslby2020-11-01 09:55:15
SQLite
jslby, 2020-11-01 09:55:15

How to work with sqlite3 asynchronously?

Hello!
I can't figure out the database in nodejs.
At the input: the list of pages for parsing is stored in the database
The script goes to the page, gets the necessary data from it and deletes the record with this line from the database.

The problem is that you need to somehow simultaneously receive the record and delete (Redis.pop), so that while waiting, another "thread" (asynchronous execution) does not take this record while we are parsing it.
The work goes very quickly and the whole script is on callback, it happens that the same record is parsed 50-100 times.

Question: how to organize everything correctly? Changing the database or losing asynchrony is not an option, a Redis database would do, but sqlite is needed.
Is it possible to combine SELECT and DElETE into one transaction in this example?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Yakushenko, 2020-11-01
@kshnkvn

No way. SQLite is just a regular file that is written to with SQL syntax.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question