A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/mathisonian/dbify below:

mathisonian/dbify: Browserify transform to inline the results of SQL queries

Browserify transform to inline the results of SQL queries

var dbify = require('dbify');
var data = dbify('select * from "table"');

becomes

var data = [{"id":1,"value":"first val"},{"id":2,"value":"second val"},{"id":3,"value":"third val"}];
$ npm install dbify

# Then add one of the following depending on which DB you plan to use:
$ npm install pg
$ npm install sqlite3
$ npm install mysql
$ npm install mysql2
$ npm install mariasql
$ npm install strong-oracle
$ npm install oracle
$ npm install mssql

and use it with browserify like

$ browserify -t dbify input.js -o output.js

see https://github.com/substack/browserify-handbook#transforms for more info on browserify transforms.

Under the hood this project relies on knex. To see full configuration documentation see http://knexjs.org/. In your package.json file add a dbify field:

sqlite example:

{
  "..."
  "dbify": {
    "client": "sqlite",
    "connection": {
      "filename": "database.sqlite"
    }
  }
}

mysql example:

{
  "..."
  "dbify": {
    "client": "mysql",
    "connection": {
      "host" : "127.0.0.1",
      "user" : "your_database_user",
      "password" : "your_database_password",
      "database" : "myapp_test"
    }
  }
}

MIT


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4