Drag the edges to resize the window.

In Projects, you can keep track of your progress as you go throught the tasks. Check each item as you complete it!

Code Editor
Learn Node SQLite

Retrieving All Rows

In the previous exercise we were able to import the 'sqlite3' library and use that to open our SQLite database — so far so good! But we still haven't retrieved any information from it. Since we have access to our database as a JavaScript object, let's try running a query on it. Recall that a query is a statement that speaks to a database and requests specific information from it. To execute a query and retrieve all rows returned, we use db.all(), like so:

db.all("SELECT * FROM Dog WHERE breed='Corgi'", (error, rows) => { printQueryResults(rows); });

In the previous example, we used the db.all() method to retrieve every dog of breed "Corgi" from a table named Dog and print them.

Report a Bug
If you see a bug or any other issue with this page, please report it here.