How to Download and Install SQLite
Open your terminal and run this command:
If by any reason you don't have it installed. It's simple to install.
- Visit the downloads page.
- Download sqlite-autoconf-XXXXXXX.tar.gz.
- Run the following commands from your terminal window:
cd ~/Downloads #or where you saved the tar file. tar xvfz sqlite-autoconf-XXXXXX.tar.gz cd sqlite-autoconf-XXXXXXX ./configure --prefix=/usr/local make make install
Remember to replace sqlite-autoconf-XXXXXXX with your file. It should look something like sqlite-autoconf-3350200. (This was the file at the time of this post.)
Installing SQLite with Homebrew
If you're already familiar with Homebrew and have it installed, then you can just run this command:
brew install sqlite3
Creating your first database
- Open the terminal and type sqlite3 cars.db
- Then run the statements below:
If you want to copy and paste the code, here it is:
create table favorite_cars(Year integer, Make varchar, Model varchar); insert into favorite_cars values(2003,"BMW","M3"); select * from favorite_cars;
Your database will be created in the folder path that you ran the sqlite3 cars.db command.
In my case this is where it was created: