From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Creating SQLite database

Creating SQLite database

Let's start by creating a database. Since this is a serverless technology, you don't need to run the database server on some port like in MySQL. Here the database is stored as a file. So let's create database by creating a file. I'll name it mydb.sqlite. database is created and on opening the file at the moment there is nothing inside it. So let's execute a query to create a table. And to do so, we'll need SQL file where we can write and execute the queries. Let us do that. I'll name the file mydb.sql. And inside it, let's write the query to create a table. I'll say create table, products, ID, int, not null, name, text, price, real. Let's save and I'll open the command palette and search for SQLite. Here we select the use database option and select the mydb.sqlite. So now the queries will be executed on mydb.sqlite. All right now to run the query, you can either right click and select this option or use shift plus command or control Q. I'll select the option. And now let's check if…

Contents