Created
December 16, 2015 20:44
-
-
Save lizTheDeveloper/3e0b1430e130ce074764 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pg = require("pg"); | |
var client = new pg.Client("postgres://localhost:5432/books"); | |
client.connect(function(err) { | |
if (err) throw err; | |
client.query("SELECT title FROM books;", function(err, result) { | |
console.log(result.rows); | |
}); | |
client.query("INSERT INTO books (title) VALUES ('Against The Fall of Night')", function(err, result) { | |
console.log(err); | |
if (!err) { | |
console.log("Inserted against the fall") | |
} | |
}); | |
client.query("INSERT INTO books (title) VALUES ('Harry Potter and the Awesome Stone')", function(err, result) { | |
console.log(err); | |
if (!err) { | |
console.log("inserted harry potter") | |
} | |
}); | |
var myBook = "Squirrel Seek's Chipmunk" | |
client.query("INSERT INTO books (title, author) VALUES ($1, $2)",[myBook, "David Sedaris"],function(err, result) { | |
console.log(err); | |
if (!err) { | |
console.log("inserted some kind of book") | |
} | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment