Results 1 to 1 of 1
Oct 3, 2010, 21:35 #1
- Join Date
- Oct 2010
- 0 Post(s)
- 0 Thread(s)
How do I use the sqlite console to paste in SQL?
I'm really new to ROR and teaching myself, so apologies for what might be a basic question. I'm reading 'Simply Rails 2' and I've reached a section (see below) where it is telling me to enter in SQL into the SQlite console. It indicates that I can easily copy and paste the code archive straight into the console I invoked... but I'm not sure how to do this.
I did enter the code in directly on the command prompt once I had drilled down to the sqlite> directory, but I'm not sure how I would have copy and pasted that in. Is there some tool or software add-on I can use to quickly input SQL into ROR???
Help. Thanks much!
For the time being, we'll create a table using the old-fashioned approach of entering SQL into the SQLite console. You could type out the following SQL commands, although typing out SQL isn't much fun. Instead, I encourage you to download the following script from the code archive, and copy and paste it straight into your SQLite console that you invoked via the following command in the application directory:
$ sqlite3 db/development.sqlite3
Once your SQLite console is up, paste in the following:
Example 4.2. 02-create-stories-table.sql
CREATE TABLE stories (
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
"name" varchar(255) DEFAULT NULL,
"link" varchar(255) DEFAULT NULL,
"created_at" datetime DEFAULT NULL,
"updated_at" datetime DEFAULT NULL
You needn't worry about remembering these SQL commands to use in your own projects; instead, take heart in knowing that in Chapter 5 we'll look at migrations. Migrations are special Ruby classes that we can write to create database tables for our application without using any SQL at all.