Skip to content

lalkmim/sheets2sqlite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sheets2sqlite

JavaScript library that converts data from google spreadsheets into a client-side in-memory sqlite database.

Pre-requisites

Usage

  1. On the spreadsheet, the first two lines should have table meta data, and from the third down the actual data.

1.1) First line: the column name and type like "id(int)"

1.2) Second line: column keys or indexes, comma-separated, with the following pattern:

1.2.1) Foreign key like "fk(referenced_table.referenced_column)"

1.2.2) Regular indexes like "in_index_name"

1.2.3) Unique indexes like "un_index_name"

1.3) Third line and below: actual data

  1. On your page, include sheets2sqlite.js file after jquery and sql.js
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/sql.js"></script>
<script src="js/sheets2sqlite.js"></script>
<script src="js/demo.js"></script>
  • On page load, run the following:
$(document).ready(function() {
    var db = new window.SQL.Database();
    var workbookId = '1jY9BZne07LoR1nvJm-PLsmQPY6jIKkkdYtuwcjMlQwA';
    var tablesToProcess = ['department', 'employee'];
    
    var functionToRun = function() {
        console.log('done!');
    }
    
    var process = new Sheets2sqlite(db, workbookId, tablesToProcess);
    process.start(functionToRun);
});

Demo

Google Spreadsheet: https://docs.google.com/spreadsheets/d/1jY9BZne07LoR1nvJm-PLsmQPY6jIKkkdYtuwcjMlQwA/pubhtml

Database loaded: https://rawgit.com/lalkmim/sheets2sqlite/master/demo.html

About

JavaScript library that converts data from google spreadsheets into a client-side in-memory sqlite database

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published