Skip to content

Instantly share code, notes, and snippets.

@davidmcclure
Last active October 13, 2015 07:57
Show Gist options
  • Save davidmcclure/4163545 to your computer and use it in GitHub Desktop.
Save davidmcclure/4163545 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