2014년 12월 6일 토요일

Using Database on App Inventor 2

How can I setup one Database on my app?

My structure is with just one table: Fishes(name,species, tempmin,tempmax,phmin,phmax)

And in this system I must be able to do a CRUD with these datas. When this App will be compiled the DB must me loaded to.

How can I do this? I should use TinyDB for this? Anyone knows?

I never used DB on App Inventor before.



Hi Marcus.  Yes, use a TinyDB.  I'm not sure what the CRUD you want to do is.  If it's web based, you'll have to use an online database and a TinyWebDB...



https://en.wikipedia.org/wiki/Crud

Crud or CRUD may refer to:



As indicated, you can use TinyDB where you can use key / values where key is the tag (e.g. fish name) and value is data you want (species, tempmin,tempmax,phmin,phmax)

If tag not found, then you'll have to add it Create
If tag found, then Read is done and you can do UD

Your values can be a string where you use a delimiter; e.g. pipe (|) to separate. Once you get the value; split to get individual tokens.



If you want the database on your Android, Marcus, there is one option:  TinyDB.    You can also manage csv files with the File component and it may be possible to use the Web component to save information in an xml file.  The TinyDB is your best bet.  The TinyDB is a kind of 'dumb' database...you have to write code to select, find , read and update data into it.

If you need a SQL database (standard query language), you have few easy options and none on the device.  The Android has to talk to stuff on the Internet: a Google Fusion table works with the generic controls provided by AI2.   Some of the Google products can be used if you are a very clever programmer or there is some third party code that is available for sale to use with AI2.  To understand a Fusion table, see the Pizza Party tutorial ...it is with the MITs tutorials    http://appinventor.mit.edu/explore/ai2/tutorials.html

To learn more about AI2 programming quickly, read the AI2 free online eBook  http://appinventor.mit.edu/explore/ai2/tutorials.html   ... the links are at the bottom of the Web page.

To work with your database regardless of what you method you choose, you will have to work with Lists:
========

To work with a TinyDB, these tutorials explain a lot:
TinyDB


================




some database interfaces you can find here https://puravidaapps.com/tutorials.php#db



Thank you so much for the help.

My App is specific for Aquarism. I have one sensor for pH and one sensor for temperature, both connected on Arduino board. These informations, pH and temperature, are sent by a Bluetooth module to the App in cellphone. This App catch these informations and attribute to two different variables, tempValue and pHValue. The DB will store the fish's informations like name, appropriate pH (minimum and maximun) and temperature (minimum and maximum) for live. The App will get these informations and will show the appropriate fish for that ambient.

So I can do this  with TinyDB?



So I can do this  with TinyDB?
yes you can, however TinyDB can store only tag/value pairs, but a value can also something complex like a list or list of lists


댓글 없음:

댓글 쓰기