#1 2016-03-25 17:43:46

romarom
Member
Registered: 2016-03-20
Posts: 24

sqlite javascript

Hello
connecting a sqlite database with javascript, and can give an example?
regards

Offline

#2 2016-03-25 19:47:00

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

Hello,

I am not an expert in this field, but, a quick search in Google point us to this StackOverflow thread, where an sql.js project is mentioned. So take a look at all of theese resources: continue the search in Google, read the StackOverflow thread and finally take a look at the mentioned JS project and probably others if you can found them.

Anyway, remember we can deal with JSON, text files and the app's local storage "out of the box", then maybe you no need SQLite at all, except if you need to consume already existing data in SQLite...

Offline

#3 2016-03-25 22:28:25

edunt
Member
Registered: 2015-12-21
Posts: 258

Re: sqlite javascript

Hi romarom,

Maybe this might be useful for you:

SQLite compiled to javascript

https://github.com/kripken/sql.js/ and


Reading a Sqlite database using client-side javascript

http://captaindanko.blogspot.co.uk/2014 … using.html

Last edited by edunt (2016-03-25 22:28:54)

Offline

#4 2016-03-27 11:20:38

romarom
Member
Registered: 2016-03-20
Posts: 24

Re: sqlite javascript

prejudice and Happy Easter to all of the form, I thank you for their statements, but I can not understand the connection of a javascript file and call up the various functions in the external JavaScript file, if you could kindly vare I wrote a small example.
regards

Offline

#5 2016-03-27 12:18:51

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

Hello,

Happy Easter too! Please, romarom, take a look at the External app sample included by App Builder. That sample show us how we can use Javascript from our applications. No matter if we use Javascript declared in certain Javascript file, which you know we can include in the application from the app's file's manager. On the other hand, can I ask why you need to access Sqlite?

If you want, for example, to store user's or app's options, we can do it without the need to use any external Javascript at all, for example, using the app's local storage.

Offline

#6 2016-03-27 12:58:18

romarom
Member
Registered: 2016-03-20
Posts: 24

Re: sqlite javascript

with my application I always used SQLite, I believe to manage data in sqlite and a good database.

Offline

#7 2016-03-27 13:02:09

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

Hello,

But you are trying to porting some application into App Builder? I say you have other options to manage data without the use of SQLite. I have anything againts SQLite, but the current browsers' support is not quite good, and we have alternatives. Depending what you want we can take one or other approach. For what kind of information you need to use an SQLite database?

P.S. Of course you can continue trying to use SQLite following the above links.

Offline

#8 2016-03-27 14:47:01

romarom
Member
Registered: 2016-03-20
Posts: 24

Re: sqlite javascript

you can even change for the JSON data source, but seen from the examples of your App Bulder es. Database and to report report9 I noticed that you are using PHP as a language to access the JSON data, even here to manipulate JSON data we need PHP as a language? For Sqlite data and a long time since I use it and for language programs for Android phones, iOS, Windophone for the moment and the best.
Greetings and thanks for your availability

Offline

#9 2016-03-27 14:51:29

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

Hello,

No. PHP is not needed at all to deal with JSON, except if the JSON come from a server. We can deal with JSON data (text files and "real" JSON objects) from App Builder without PHP or any server assistance. In fact, we can read and write JSON data and store it into the app's local storage (various MB at our disposition) and we can also read and write JSON text files (with more space available), using the Files Cordova's plugin, which is ready out of the box in App Builder.

As I say before, what must be our approach depend on the application we are developing.

Offline

#10 2016-03-27 15:12:40

romarom
Member
Registered: 2016-03-20
Posts: 24

Re: sqlite javascript

I could think of an example of App Builder working with JSON Cordova's plugin, have just that I use your software, as I mentioned earlier I programmed with Basic4Android (basic language), if I were to buy your software I would like to understand it well.
Thank you

Offline

#11 2016-03-27 15:49:56

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

Hello,

Maybe you can take a look at the samples included by the proram romarom. We no need any Cordova's plugin to deal with JSON. We can use action slike NewObject, SetObjectProp, StrSerialize, StrUnserialize, SetOption, GetOption, etc. The Report control is also capable to parse JSON automatically. We only need a Cordova's plugin (the Files plugin) if we want to store more than the Mega Bytes allowed by the app's storage, which can vary between browsers.

App Builder already includes samples which deal with JSON, however, I want to add another one (some kind of "Agenda" sample) when possible.

Offline

#12 2016-03-27 16:04:34

romarom
Member
Registered: 2016-03-20
Posts: 24

Re: sqlite javascript

thanks for your time,

Offline

#13 2016-03-27 16:06:25

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

No problem! smile

Offline

#14 2016-03-27 20:42:52

tin
Member
Registered: 2016-03-20
Posts: 161

Re: sqlite javascript

I come from Basic4android and Basic4IOS too big_smile big_smile .I like App builder now tongue
Love to see some example with sqlite database(internal app database).
Your "database" example with php web service connect mysql was very easy to understand!.

Last edited by tin (2016-03-27 20:43:57)

Offline

#15 2016-03-28 10:45:23

romarom
Member
Registered: 2016-03-20
Posts: 24

Re: sqlite javascript

hello tim, basic4android and basic4ios course are alternative programs without knowing java well as their knowledge and basic, and indeed with the help of libraries and a good very broad forum, in the App Builder and a great software for HTML5 code and very fast, the problem that there are few resources, another problem and that written in HTML code and therefore do not support the broweser ila SQlite source data, as I noticed entering the javascript code to access Sqlite, those not familiar with java will very difficult.
regards

Offline

#16 2016-03-28 13:18:32

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

Hello to all,

Update your AB copies and take a look at the new "Agenda" app sample:

Add the new Agenda app sample, which simulates an small agenda to save our contact's names, mobile numbers and notes. The point of this application is they use JSON to store the contacts' data, uses a Report control to shown the contacts information and finally uses the app's local storage to maintain the data between application executions.

Hope they can help anybody about JSON, the Report control and the app's local storage.

Offline

#17 2016-03-28 19:28:29

tin
Member
Registered: 2016-03-20
Posts: 161

Re: sqlite javascript

I test new sample "Agenda" app sample.Where the path json file save? thanks

Offline

#18 2016-03-28 19:29:47

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

Hello,

tin wrote:

I test new sample "Agenda" app sample.Where the path json file save? thanks

There is no path at all, tin, but the application uses their local storage to save the JSON data.

Offline

#19 2016-03-28 23:30:19

romarom
Member
Registered: 2016-03-20
Posts: 24

Re: sqlite javascript

because uses local memory, you can not even create its own JSON files in a directory eg files app?

Offline

#20 2016-03-28 23:33:31

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

Hello,

romarom wrote:

because uses local memory, you can not even create its own JSON files in a directory eg files app?

Browsers don't allow a web application to save their data in the system file system. Some technologies may appear in the future, but currently they are not wide supported by the browser's vendor. If we plain to use the application in a mobile environment, then we can use the Apache Cordova's "Files" plugin (take a look at the "Files" app sample) and then we can store the JSON text in to files without problems.

Offline

#21 2016-03-29 08:27:15

tin
Member
Registered: 2016-03-20
Posts: 161

Re: sqlite javascript

So,For now offline database need to use json.And online use webservice(vis php or other) to connect any database.Right?

Offline

#22 2016-03-29 09:18:51

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

Hello,

Database... we can use the local storage for our application's data: options, preferences, etc. Since the local storage wanted for strings (to be saved) and we can serialize JSON objects to strings... then we can save JSON data into the app's local storage, which is something useful. But we can also saved the information in another possible way, using the same local storage.

Certainly, client side databases is not widely supported, then, if we need real databases, probably we want to use server side ones, then no matter if we want to use MySQL or any other database engine, since our client applications are abstracted of that.

Offline

#23 2016-03-30 11:21:15

romarom
Member
Registered: 2016-03-20
Posts: 24

Re: sqlite javascript

hi, I'm trying to figure out how to call the functions in javascript, but as I look and simple, the example of Qecode not very understanding, on the other IDE when you put the point es (window. a list appears to function or to other commands qu I do not see) the classes of a file javascript there are not many manuals Sql.js like that, if you can better understand when a function or altrocomando within a javascript values that ristituisce with our appbuilder commands. thank you

Offline

#24 2016-03-30 11:26:40

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: sqlite javascript

Hello,

Use a Javascript external function is not complicated. Supose we have a Javascript file with the below code:

window.MyCuteFunction = function() {
  alert('Hi from my cute function!');
};

Then, if we include such file using the app's file's manager, we can call to "MyCuteFunction", just by include the function's call between the StartJS and EndJS actions, just like in the below code:

StartJS
  window.MyCuteFunction();
EndJS

About the "sql.js" we have the complete documentation here and also various samples in the project's page here. Currently App Buidler do not recognize external Javascript files in order to extract form such files their "reusable" stuff, honestly I don't know if this feature can be added in the future.

Offline

#25 2016-03-30 11:49:04

romarom
Member
Registered: 2016-03-20
Posts: 24

Re: sqlite javascript

ok for example, but if I with a call to javascript I have to see the result es. (iwindow.App.RootScope.Input1.value window.MyCuteFunction = ();) I see not, and in the choir because imput1 boxes not ristituisce anything.
thank you

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.