mardi 12 janvier 2016

Creating HTML Tables from SQLite Database

I am trying to create dynamic HTML tables from SQLite source data. More specifically, I'd like to initialize a number of DataTables (https://datatables.net/) with the source data coming from a SQLite database. I already have all of the necessary SQLite data in the database, but I'm kind of unsure on the best way to fetch that data from the database to initialize DataTable objects.

Based on the research I have done up to this point, I think my best bet would be to write some Javascript to fetch the data from the SQLite database, store it as an array, and then initialize the DataTables as such:

$(document).ready(function() {
$('#TableID').DataTable( {
    data: inputArray,
    columns: [
        { title: "Col1" },
        { title: "Col2" },
        { title: "Col3" }
    ]
} );
} );

This is coming from their example here: http://ift.tt/1p5IwBR

Am I right in thinking that this is "best practice" for how fetching SQLite data should be done? If so, I could use a little guidance on how to pull data from SQLite using javascript. Any tutorials I have found seem to all offer different solutions, really I just need the most basic functionality to simply pull data from the related tables. All of my source data is already in the SQLite database from another portion of my application.

Any insight would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire