0

Hello I am practising and learning SQLite,

I created a SQLite file manually on VSCODE I call the file project_1.sqlite but when I try run the command

sqlite3 project_1.sqlite i get

$ sqlite3 project_1.sqlite
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
sqlite> 

then when I say SELECT * FROM friends; I get

sqlite> SELECT * FROM friends;
Error: file is not a database
sqlite> 

I have already set up my SQLite inside the Control Pannel

Why am I getting the Error: file is not database ??

my project_1.sqlite file I already have populated it like this:

CREATE TABLE friends (
  id INTEGER,
  name TEXT,
  birthday DATE
);

INSERT INTO friends (id, name, birthday)
VALUES (1, 'Ororo Munroe', '1940-05-30');

INSERT INTO friends (id, name, birthday)
VALUES (2, 'Sham', '1990-01-01');

INSERT INTO friends (id, name, birthday)
VALUES (3, 'Maria', '1991-01-01');

UPDATE friends
SET name = 'Storm'
WHERE id = 1;

ALTER TABLE friends
ADD COLUMN email TEXT;

UPDATE friends
SET email = 'storm@bffemail.com'
WHERE id = 1;

UPDATE friends
SET email = 'sham@bffemail.com'
WHERE id = 2;

UPDATE friends
SET email = 'maria@bffemail.com'
WHERE id = 3;

DELETE FROM friends
WHERE id = 1;

SELECT * FROM friends;

I have Windows but I have installed Bash so I am using Bash commands hope that makes sense I dont have Linux I am new to Programming as well sorry

Mohamed
  • 425
  • 4
  • 14
  • This is answered here: https://stackoverflow.com/questions/48974135/sqlite-error-file-is-not-a-database – Leo Jul 23 '21 at 17:44
  • 1
    Does this answer your question? [Sqlite Error: file is not a database](https://stackoverflow.com/questions/48974135/sqlite-error-file-is-not-a-database) – Leo Jul 23 '21 at 17:44
  • @Leo I tried that ```sqlite3``` then ```.open project_1.sqlite``` then still when I do ```SELECT * FROM friends;``` I still get the same error: ```Error: file is not a database``` – Mohamed Jul 23 '21 at 17:58
  • Is that the contents of your project_1.sqlite? A text file with a bunch of sql statements in it is **not** a SQLite database. – Shawn Jul 23 '21 at 22:39
  • @Shawn I put their .sqlite extension why wont that work? I thought that would make it a database – Mohamed Jul 24 '21 at 18:58
  • Huh? You can give a file any extension you want; that doesn't magically turn it into a particular format. – Shawn Jul 24 '21 at 21:35
  • @Shawn if I where to name a file .js or .py that would make the file a JavaScript or Python file format. So why wont .sqlite make the file a sqlite database file? I found this very strange – Mohamed Jul 24 '21 at 23:12

0 Answers0