Skip to content

Instantly share code, notes, and snippets.

@murindwaz
Forked from davidmcclure/gist:4163545
Created August 9, 2013 03:00
Show Gist options
  • Save murindwaz/6190856 to your computer and use it in GitHub Desktop.
Save murindwaz/6190856 to your computer and use it in GitHub Desktop.
var mysql = require('mysql');
var client = mysql.createConnection({
host: 'localhost',
user: 'omeka',
password: 'omeka',
port: 8889,
database: 'neatline'
});
client.connect();
// Create exhibit.
var sql = 'INSERT INTO exhibits (title) VALUES ("dev")';
client.query(sql, function(err, res) {
// Create row, using the insert id of the first query
// as the exhibit_id foreign key.
sql = 'INSERT INTO records (exhibit_id) '+
'VALUES('+res.insertId+')';
client.query(sql);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment