Setting up SQLite on Mac - .schema not working

https://www.codecademy.com/articles/what-is-sqlite

I am on a mac. As per linked article, downloaded and installed sqlite. Downloaded and installed acs-1-year-2015.sqlite database as instructed. All saved to desktop (in a folder titled SQL Related).

Changed directory to Desktop (cd Desktop) from terminal. That is perfect.

Theresas-iMac:Desktop theresaraegay$ was my command line and I typed
sqlite3 acs-1-year-2015.sqlite and clicked enter.

This came up. I think it is right?
SQLite version 3.28.0 2019-04-15 14:49:49
Enter “.help” for usage hints.
sqlite>

So, as directed, I typed .schema. Nothing happened.

I typed .help and received a full list of help areas so it is working.

Thoughts? Not sure what to do if I cannot see schema of DB.

Thank you -

1 Like

Hi, welcome to the forums :slight_smile:

It’s been a long time since I’ve done this setup from CC (but I do use Sqlite so I can help a little).

This might be a silly question, but are you sure the file has a schema? If you have DB Browser (there’s a version for mac) you can visually browse the database to verify this.

2 Likes

@object9507334711,

It sounds like you probably created a database called acs-1-year-2015.sqlite rather than opening the one you have. That would mean there are no tables to show, and hence, no schema.

The reason this would happen is because when SQLite tries to open a database file, if that file is not where you tell SQLite to look, SQLite will create a database file with the name you supplied at that location. So, always make sure you open your command line to the same folder as your database file in order to avoid this in the future. :slight_smile:

2 Likes

That makes sense, I didn’t think of it not being in the same folder … :sweat_smile:

I am following the directions from that linked page. He says to type it and he shows what happens when he does. Mine doesn’t.

Like @el_cocodrilo points out it’s probably a file location issue then.

A way you can make sure you’re on target it to type ls in the directory where you are and confirm that the file you want to open is there. I would re-download the file at this point to make sure that it’s the original and not one that sqlite created by default. (Conversely, you can check if it’s the right one with DB Browser, again, highly useful tool).

1 Like