var sqlite = require('sqlite');
var Step = require('step');

function MBTiles(filename, options) {
  this.filename = filename;
  this.options = options || {};
  this.db = new sqlite.Database();
}

MBTiles.prototype.setup = function(callback) {
  this.open(function(err, db) {
    err && console.log(err);
    db.executeScript(
      'CREATE TABLE IF NOT EXISTS tiles ('
      + 'zoom_level integer, '
      + 'tile_column integer, '
      + 'tile_row integer, '
      + 'tile_data blob);'
      + 'CREATE UNIQUE INDEX IF NOT EXISTS tile_index on tiles '
      + '(zoom_level, tile_column, tile_row);'
      + 'CREATE TABLE IF NOT EXISTS "metadata" ('
      + '"name" TEXT ,'
      + '"value" TEXT);'
      + 'CREATE UNIQUE INDEX IF NOT EXISTS "name" ON "metadata" '
      + '("name");', function(err) {
          err && console.log(err);
    });
  });
};

MBTiles.prototype.metadata = function(callback) {
  this.open(function(err, db) {
    err && console.log(err);
    db.executeScript(
      'CREATE TABLE IF NOT EXISTS tiles ('
      + 'zoom_level integer, '
      + 'tile_column integer, '
      + 'tile_row integer, '
      + 'tile_data blob);'
      + 'CREATE UNIQUE INDEX IF NOT EXISTS tile_index on tiles '
      + '(zoom_level, tile_column, tile_row);'
      + 'CREATE TABLE IF NOT EXISTS "metadata" ('
      + '"name" TEXT ,'
      + '"value" TEXT);'
      + 'CREATE UNIQUE INDEX IF NOT EXISTS "name" ON "metadata" '
      + '("name");', function(err) {
          err && console.log(err);
    });
  });
};

MBTiles.prototype.open = function(callback) {
  var that = this;
  this.db.open(this.filename, function(err) {
    callback(err, that.db);
  });
};

var x = new MBTiles('test.mbtiles');

require('eyes').inspect(x.setup(function() {}));

@@ -229,32 +229,51 @@
 ion(callback) %7B%0A
+  var that = this;%0A
   this.open(func
@@ -273,39 +273,32 @@
 en(function(
-err, db
 ) %7B%0A    
 err && conso
@@ -289,37 +289,13 @@
     
-err && console.log(err);%0A    
+that.
 db.e
@@ -292,38 +292,32 @@
  that.db.execute
-Script
 (%0A      'CREATE 
@@ -1646,91 +1646,30 @@
 %7D;%0A%0A
-var x = new MBTiles('test.mbtiles');%0A%0Arequire('eyes').inspect(x.setup(function() %7B%7D))
+module.exports = MBTiles
 ;%0A

Update parts of mbtiles for new sqlite module.