AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.01k stars 653 forks source link

alasql attaching to sqlite #529

Closed agershun closed 8 years ago

agershun commented 8 years ago

Source: Stackoverflow.com

TANACH_6_1.db exists at the same location as the following HTML. It runs (no errors) but nothing appears at the terminal. Have checked and rechecked syntax and looked at several examples. Tested sql in "SQLEXPERT". alasql is working as I was able to create an in memory database. Please help:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>AlaSQL - JavaScript SQL database console</title>
    <link rel="stylesheet" href="style.css" type="text/css">
    <script src="js/xlsx.core.min.js"></script>
    <script src='js/alasql.min.js'></script>
    <script src='js/sql.js'></script>
    </head>
    <body>
    <script>
    alasql('ATTACH SQLITE DATABASE tanach("TANACH_6_1.sqlite");
    USE tanach;
    SELECT verse from bookChapterVerse where bookChapterVerseID = 614',[],function(res){console.log("result:",res.pop());});
    </script> 
</body>
</html>
agershun commented 8 years ago

May be the problem with the structure of 'TANACH' database...

levinemartin63 commented 8 years ago

I created a new database called test with one table called x with one value using the SQLite expert personal. and entered the following <!DOCTYPE html>

AlaSQL - JavaScript SQL database console #

nothing on the screen. The "attach statement causes the HTML to fail, i.e. if you try to enter alert("here") it fails if the attach statement works. My request. Send me or give me access to any simple SQLite database that works so I can see if it works in my environment (i.e. browser, server, etc.)

thanks for the help

levinemartin63 commented 8 years ago

sorry error in my last statement. if you try to enter alert("here") in front or after the "ATTACH" statement the HTML fails. take out the "ATTACH" and the HTML alert works not the attach.

levinemartin63 commented 8 years ago

If it makes sense I can somehow send my test.db

agershun commented 8 years ago

Please, send it to me. agershun at gmail.com

agershun commented 8 years ago

This is working example:

http://alasql.org/demo/016sqlite/

The database:

http://alasql.org/demo/016sqlite/Chinook_Sqlite.sqlite

levinemartin63 commented 8 years ago

Andrey,

fixed: thanks for the quick response. Got your db and mine to work locally; combination of file naming errors and having sql.js in the right place.

one other question: I also tried alert(res[0].bookChapterVerseID) after "...select bookChapterVersID from bookChapterVerse" and got undefined as the result. Seemed to work with a test using the a simple db in the "in memory" version but not here. Sorry I did some research on JSON and know little about it. Thanks for any additional help.

Marty

Date: Mon, 18 Jan 2016 11:57:53 -0800 From: notifications@github.com To: alasql@noreply.github.com CC: levine_martin@hotmail.com Subject: Re: [alasql] alasql attaching to sqlite (#529)

This is working example:

http://alasql.org/demo/016sqlite/

The database:

http://alasql.org/demo/016sqlite/Chinook_Sqlite.sqlite

— Reply to this email directly or view it on GitHub.

agershun commented 8 years ago

Could you compare: alert(res[0].bookChapterVerseID) and select bookChapterVersID from bookChapterVerse"?

Here you use different column names: bookChapterVerseID and bookChapterVersID (without e)

levinemartin63 commented 8 years ago

thanks for looking, that wasn't the issue as it was correct in the code.

I wrote a little function to parse the results and learn more about JSON.

I integrated the example that I used for testing into the project I am working on and everything works fine so far.

Thanks again for the help.

Marty Date: Tue, 19 Jan 2016 04:48:50 -0800 From: notifications@github.com To: alasql@noreply.github.com CC: levine_martin@hotmail.com Subject: Re: [alasql] alasql attaching to sqlite (#529)

Could you compare: alert(res[0].bookChapterVerseID) and select bookChapterVersID from bookChapterVerse"?

Here you use different column names: bookChapterVerseID and bookChapterVersID (without e)

— Reply to this email directly or view it on GitHub.

mathiasrw commented 8 years ago

Glad to know you found a solution. Can we close this issue?

levinemartin63 commented 8 years ago

yes thanks

Date: Tue, 19 Jan 2016 15:33:12 -0800 From: notifications@github.com To: alasql@noreply.github.com CC: levine_martin@hotmail.com Subject: Re: [alasql] alasql attaching to sqlite (#529)

Glad to know you found a solution. Can we close this issue?

— Reply to this email directly or view it on GitHub.