As a novice programmer with 20-hour Python coding and familiarity with the command line, I opened Zed Shaw's “Learn SQL The Hard Way” and was quickly puzzled.
In exercise 01 , Zed created the first table with this first command:
sqlite3 ex1.db < ex1.sql
However, this cannot be done on my command line with the error message: "bash: ex1.sql: there is no such file or directory." I initially ignored this recommended code and continued:
sqlite3 ex1.db SQLite version 3.7.15.1 2012-12-19 20:39:10 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> CREATE TABLE person ( ...> id INTEGER PRIMARY KEY, ...> first_name TEXT, ...> last_name TEXT, ...> age INTEGER ...> );
Running "ls -l" on the command line shows:
-rw-r--r-- 1 thefifth staff 2048 Feb 15 15:23 ex1.db
But I want and cannot get:
$ ls -l -rw-r--r-- 1 zedshaw staff 2048 Nov 8 16:18 ex1.db -rw-r--r-- 1 zedshaw staff 92 Nov 8 16:14 ex1.sql
I figured out and found this blog that implements the same syntax "name.db <name.sql", but after that the code didn’t work here either. This Stack Overflow also has a similar syntax, but in the context of converting .sql to sqlite3.
In particular, I am wondering if this is a "<" for use in the native bash terminal and that I do not meet certain criteria for its proper use. Also, I don’t know the purpose of creating the .sql and .db file, although apparently it is much smaller than the other. I may have installed sqlite3 incorrectly, but it seems to be working fine.
Thank you for your help!
source share