AsteroidDB - A database service for AI2, based on TinyWebDB

asteroiddb-cropped    AsteroidDB
Hi everyone!

I want to introduce you my new database service AsteroidDB which helps you save data online (like Firebase, TinyWebDB) but AsteroidDB is much simplier to setup and its source is open-source. :grin:

It’s structrue is based on TinyWebDB, and it is a cloned and improved project from Pavitra’s TinyWebDB repository which coded in Python. I added new methods and named it as AsteroidDB, because it is not a “Tiny” database service anymore :sweat_smile: And as it is works with HTTP requests, I wrote an extension for App Inventor, so you can use it in App Inventor directly.

Data

AsteroidDB is 2 column data table, tags and values. When you want to get/delete or modify the value of a record you need to know its tags. (Like you do in TinyDB)

Methods

TinyWebDB has 2 methods; get value and store value .

But AsteroidDB has these methods:

  • Store - Stores a new value or changes existing one.
  • Get Value - Returns a value using its tag.
  • Get All Data - Returns all tags along with values.
  • Get All Tags - Returns all tags.
  • Delete - Deletes one record.
  • Format - Deletes all records.
  • Set Password - Sets a new password or changes the current one.
  • Unlock - Removes password protection.
  • Count - Counts records.
  • Is Locked - Returns true if database is locked with a password. Otherwise, false .
  • Is True - Returns true if database password is same with entered password, useful for checking the password before connecting to the database.

Events / Methods

Properties

image

Security

You can set a password to your AsteroidDB instance, setting a password will require a password for every data operation. Password is keeping as a record in database with “dbpass” tag, however no any method will allow you to read the password of course. :sweat_smile:

Hosting

AsteroidDB is coded with Python and uses Flask, Flask_SQLAlchemy, gunicorn and psycopg2 libraries. So it can be installed on any environment which support these. But I recommend using Heroku (cloud application platform) because it has a one-click deploy feature which allows to create a new AsteroidDB instance with one-click.


Quick Start

  1. Click this button and create a Heroku account (if you don’t have one).
    Deploy

  2. After end of the build log, Heroku will give you a URL which you can access your deployed app.

  3. Open your App Inventor project, Import the AsteroidDB extension and fill the properties.

After that, you can now use blocks to manage your database! That’s it! As you deployed your app on Heroku, it uses your Heroku account’s plan.

Details

However, Heroku’s free plan offers 10.000 rows/records and maximum connection limit is 20. You should pay for Heroku if you want more storage. If you don’t want to host on Heroku, you can host AsteroidDB in VPS also.


Resources

Download Extension

Allows to manage your AsteroidDB instance in App Inventor platform.
Latest AsteroidDB for App Inventor Extension (version v1.1)

Source code of extension:
https://github.com/ysfchn/AsteroidDB-AI2

Docs

Includes example snippets, update guides, method descriptions and with its return types and more!

Source Code

Web Editor

I created a client app for AsteroidDB instances to manage your database online by just typing the database URL and password.

Go to the Web Editor


Let me know if you have any questions about AsteroidDB :grin:

15 Likes

Big thx for your extension. I am beginner user and have little problem.
on site https://asteroiddbweb.herokuapp.com/ i have example table with 3 records.

i’dlike to read with my app all table. ( 2 rows and 3 records ) but i dont get any data :frowning:host

please, help me. I am very beginner.

1 Like

you should call the GetAll method outside of that event, for example in a button click event
in the OnSuccss event you get the result back…

A very good way to learn App Inventor is to read the free Inventor’s Manual here in the AI2 free online eBook http://www.appinventor.org/book2 … the links are at the bottom of the Web page. The book ‘teaches’ users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles
How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .

Also do the tutorials http://appinventor.mit.edu.ezproxy.canberra.edu.au/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

2 Likes

I did not see a URL after the deploy. Where can I find that?

Did you give your app a name?

If so use that with this:

https://< your app name >.herokuapp.com

If you login to your heroku account, your url will be there also

1 Like

Got it thanks. And the password is my password for Heroku?

Where on Heroku do I find that database file? I want to create usernames and some values associated to be used by AsteroidDB.

Having had a look, I do not think you can access the actual data through the heroku web platform. You will have to add your users through your appInventor app (or make another, “admin” app to manage users.

Heroku doesn't provide seeing data in own dashboard, you need to use external services or you can create a simple app in App Inventor to set your password.

OK, going back to the app that needs username, and points assigned, how does that work since we only have tags and values?

Tag - Username
Value - Bluejay

Tag- Points
Value - 100

But what about the different point values for different usernames? Can someone point me in the right direction for a tutorial?

Make a list for each user tag = username (whatever/ID) value = list of [ID,username,pointsValue]

Or store a dictionary for each user tag = username (whatever/ID) value = {“ID”:76,“username”:“ABG”,“pointsValue”:42}

This switches from having to remember which column number has what to having to remember which subtag has what, with better default handling and growth accommodation.

It is not that hard to remember 3 things, is it …?

I think I jumped into this too soon without knowing even TinywedDB. Which tutorial would you recommend for simple database on MIT App inventor?

The hard part is unremembering those 3 things when the data structure has to change. Ask a SQL DBA how he feels about SELECT * from tablename statements.
.

AsteroidDB and TinyWebDB are not preferred for items which has sub-items. It would be easier and better if you use FirebaseDB for this.

Hello everyone! I tried deploying the app using the heroku template via the button provided above but when it reached the building stage it failed. Showing this error message

image

It's suggesting that the build failed because python-3.7.3 is not available. I think this might be a mistake from the template? As the heroku python support article states that heroku supports:

  1. python-3.10.2
  2. python-3.9.10
  3. python-3.8.12
  4. python-3.7.12

or maybe I did something wrong? Any help would be appreciated.

Thanks in advance

try changing the runtime.txt file, there you may have the python version mentioned

1 Like