title: Accessing SQLite3 Database in NodeJS
body: <p>I'm creating a database using SQLite3 in NodeJS. I've succesfully been able to create the database with a table and insert data. If I'm in that same file and I do a select to log the data from my table it works. My question is how can I run a query on the database from another js file? I've tried using the module way but had no luck. Let's say m file that creates the databse is called</p>
  
  <p>db.js</p>
  
  <pre><code>var sqlite3 = require('sqlite3').verbose();
  var db = new sqlite3.Database('./database.db');
  
  db.serialize(function() {
  
      db.run("CREATE TABLE if not exists parameters (path TEXT)");
      var stmt = db.prepare("INSERT INTO parameters VALUES (?)");
  
  
      stmt.run("test paramter");
      stmt.finalize();
  
     db.each("SELECT path FROM parameters", function(err, row) {
         console.log(row.path);
      });
  });
  db.close();
  </code></pre>
  
  <p>Then I have a file called </p>
  
  <p>update.js</p>
  
  <p>How could I run a query</p>
  
  <pre><code>   db.each("SELECT path FROM parameters", function(err, row) {
          console.log(row.path);
      });
  </code></pre>
  
  <p>inside this js file instead?</p>