9951 explained code solutions for 126 technologies


sqliteHow do I set up a SQLite server?


Setting up a SQLite server is relatively simple.

  1. First, install the SQLite3 package for your operating system. On Ubuntu, this can be done with the following command:
sudo apt-get install sqlite3
  1. Next, create a database file. This can be done with the following command:
sqlite3 example.db

This will create a file named example.db in your current working directory.

  1. Once the database file is created, you can create tables and insert data into them. For example:
CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);
INSERT INTO users (name) VALUES ('John');
  1. To access the data in the database, you can use the SELECT statement. For example:
SELECT * FROM users;

This will output the data in the users table:

1|John
  1. Finally, you can use the .quit command to exit the SQLite3 shell.

For more information on setting up a SQLite server, see the SQLite documentation.

Edit this code on GitHub