• Sample Apps

Create a Web Database

TinyWebDB is an App Inventor component that allows you to access the web from an Android app. You can use TinyWebDB to access a data source (API) or to store the app’s  data persistently in a web database. These notes show you how to do the latter– set up a web database, and set it up in the cloud using Google’s free App Engine service. With the sample code provided here, you can set up a web database that lives on Google’s servers in just minutes, and you need not be a programmer to do so.

Note that App Inventor also provides a TinyDB component. TinyDB stores data directly on the phone and is simpler to use.  TinyWebDB is required only if data needs to be shared between phones and apps (e.g., social apps, multi-player games).

By default, the TinyWebDB component stores data on a test service provided by App Inventor, http://appinvtinywebdb.appspot.com/. This service is helpful for testing, but it is shared by all App Inventor users, and it has a limit of 1000 entries. If you use it, your data will be overwritten eventually.

For anything other than tests, you’ll want to create a custom web service that isn’t shared with other App Inventor apps and programmers. You need not be a programmer to do so– just follow the instructions below and you’ll have your own service within minutes.

To create your own web service, follow these instructions:

  • Download App Engine for Python at http://code.google.com/appengine/. Make sure and download the App Engine SDK for Python. After installing it, run the GoogleAppEngineLauncher by clicking its icon.
  • Download this sample web database code. It is a zip file containing the source code for your custom web database service
  • Unzip the downloaded zip file. It will create a folder named appinventordb. You can rename it if you want.
  • In the GoogleAppEngineLauncher, choose File | Add Existing Application. Browse to set the Path to the appinventordb folder you just unzipped. Then click the Run button. This will launch a test web service that runs on your local machine.
  • You can test the service by opening a browser and entering “localhost:8080” as the URL. You’ll see the web page interface to your web service. The end-goal of this service is to communicate with a mobile app created with App Inventor. But the service provides a web page interface to the service to help programmers with debugging. You can invoke the get and store operations by hand, view the existing entries, and also delete individual entries
  • Your app is not yet on the web, and thus not yet accessible to an App Inventor app. To get it there, you need to upload it to Google’s App Engine servers.
  • In the GoogleAppEngineLauncher, choose Dashboard. Enter your Google account information and you’ll be taken to an App Engine dashboard.
  • Choose Create an Application. You’ll need to specify a globally unique Application Identifier. Remember the Application identifier as you’ll need it later. Provide a name to your app and click Create Application to submit. If your Identifier was unique, you now have a new, empty app on Google’s servers.
  • Open a text editor on your local computer and open the file app.yaml within the appinventordb folder you unzipped. Modify the first line so that the application matches the application identifier you set at Google.
  • In GoogleAppEngineLauncher, choose Deploy and follow the steps for deploying your app.
  • Test to see if your app is running on the web. In a browser, enter myapp.appspot.com, only substitute your application identifier for “myapp”. The app should look the same as when you ran it on the local test server. Only now, it’s on the web and you can access it from your App Inventor for Android app.

App Inventor Client Apps

Once you have an “App-Inventor-compliant” web database, you can create App Inventor apps that access it. For the sample you just created, do the following:

  • Drag in a TinyWebDB component into the Component Designer.
  • Modify the ServiceURL property from the default http://appinvtinywebdb.appspot.com/ to the URL of your service.
  • Any StoreValue operations (blocks) will store data at your service, and any GetValue operations will retrieve from your service.

Here are some blocks that store and retrieve data:


56 Responses

  1. I posted this on the app inventor groups, but you guys may be way ahead on this. I would like to bulk upload data to use as a tinyWebDB source. I’ve got a list of data on a spreasheet and I’d like to get it easily into a webservice I can call from my app inventor app.

    Trying to avoid hand-keying the information like in the MakeQuiz app.

  2. HI rd. You can parse a spreadsheet (csv file) with Python/App Engine. Here’s some sample code from one of my projects:

    import csv
    reader = csv.reader(open(‘efile_newestSFO_8354d71d-e3fb-4864-b9bf-5312a89e24d7_2010.csv’,”rU”), delimiter=’,’)
    for row in reader:
    print row[0],row[1]

    It just prints out the first two columns of each row in some spreadsheet.

    So a solution might be: 1) download the sample database code here. 2) add some code that programatically loads the data from your spreadsheet, using the sample above to guide you.

    Hope this helps,


    • This import functionality is exactly what I have been looking for. Since I am not a true programmer, can you give me more guidance about where this sample import code would be placed?

      I am testing with the the customtinywebdb sample code. Would this need to be in “main.py”? If so, what section?

      Sorry for the basic question. I am not familiar with Python code.

      • Hi, I just saw this for some reason. You definitely want to change the main.py code if you want to customize a tinywebdb service. You can call another information service and do any calculations you want. Check out the “Create an API” example for where to put the custom code.

        If you just want your own database for your app, you can just deploy the sample to App Engine as is, using the instructions on this page.

  3. cant seem to get the app.yaml file edited correctly;

    application: mmc-testapp
    version: 1
    runtime: python
    api_version: 1
    – url: /images
    static_dir: images
    – url: .*
    script: main.py

    when I deploy with this, app engine gives me;

    Error parsing yaml file:
    Invalid object:
    Unknown url handler type.

    in “C:\appinventordb\app.yaml”, line 13, column 1
    2010-09-10 08:10:04 (Process exited with code 1)

    • got it to work, apparently you NEED whitespace in the app.yaml file in front of static_dir: & script:.

      • Michael, glad you got this fixed– I’ve found the yaml files to be a real head ache in terms of weird whitespace issues like the one you ran into

  4. forgive me for asking something that maybe obvious – I am getting the protocol exception error running to an iis server. I am getting the correct data in the URI from the phone (wireshark) but it seems that the php page/server is not handling the data correctly. what exactly is needed to run AI to a php page on windows server – i am all out of guesses

  5. I am curious about the security/implementation of an app that uses this service.

    If I write and create an app that uses this service and then distribute it, will all users have access to other users information? What if a user switches phones? Will they be able to recover access to their information?

  6. Hi Folks,
    I’m entering a mashup competition over here in NZ.
    I want to mash data, most of it is static so will be uploaded to a spreadsheet, but I also want to call upon an api. Some data I can access by simply adding an extension to the url eg http://www.companies.govt.nz/q=“SEARCHTERM” I’ve read the above but I’m so new to all this it doesn’t make much sense to me.
    I want to make an android app that will use the data and prompt the query terms and read the spreadsheet.
    Where should I be starting and , is it possible for me at my level to achieve this. There are quite a few people in NZ who are going to be watching the results and as far as I know I’m the only person in NZ on the AI beta, so it would be quite an achievement to win a comp like this using the AI interface. PS I have 23 days left to finish it.

  7. Mr Dave Wolber,

    I tried to import csv data to my appspot following your method:

    import csv
    reader = csv.reader(open(‘efile_newestSFO_8354d71d-e3fb-4864-b9bf-5312a89e24d7_2010.csv’,”rU”), delimiter=’,’)
    for row in reader:
    print row[0],row[1]

    (code added to my main.py, sample code from http://appinventor.googlelabs.com/learn/reference/other/tinywebdb.html)

    but it is not working.

    Could you write a tutorial explaining step by step how to parse a csv file (with two column, tag & value) to a custom tinyweb db ?

    It would be very helpful since I could find only the bulk loader chapter (http://code.google.com/intl/fr-FR/appengine/docs/python/tools/uploadingdata.html) but to tricky for a non-programmer like me !
    As far as I know, there is no other ressource on the web explaining this.

    Looking forward to your reply as my project of putting http://techdico.free.fr/ accessible to android user is blocked !

    • Hi Phillipe. Send me your code and I’ll take a look. A csv parsing tutorial would be nice but I probably won’t get to it soon.


      • I have followed your above instructions to a T. When I access my GAE tinyweb db all I get is “Hello World”, the standard response. Here is what my app.yaml file looks like: “application: lptinydb: 1
        runtime: pythonapi_version: 1 builtins: – datastore_admin: on handlers:
        – url: /images static_dir: images – url: script: main.py”. I am able to deploy and look at the Dashboard with no problem. Just can’t access the data I have entiered into my application. Yes my app inventor app is set to http://lptinydb.appspot.com. Data seems to be being loaded but I can’t see it in either my application or using GAE tools. Thanks Dave in advance for your kind help. Don

      • Hi Don. The only thing I can see strange about what you sent is the script: main.py. The sample app.yaml has:

        application: appinventordb
        version: 1
        runtime: python
        api_version: 1

        – url: /images
        static_dir: images

        – url: .*
        script: main.py

        Note the -url: .*


  8. Hi David,
    Ok I send it to your email.
    Thanks for the help !

  9. Hi,

    First of all, thank you very much. This tutorial was a great leap forward for me. However, despite following exact instructions here; my app wont load values from the db properly. It seems to bring up the latest value entry as opposed to the value of the tag I searched for. Any ideas what I’ve done?

    Thanks again,

    Ewan Valentine

  10. How would I set the Tag to increase by 1 after every post (eg- 1 + 1, 2 + 1, 3 + 1), in order to incrementally increase the tag designation.

    Also, how would I be able to display the last 50 entries as output on the page, no matter what their designated tag is?

    Any advice?



  11. If I need to get two or tree tags from my daatabase, do I the need two / tree TinyWebDB? or can one TinyWebDB be used with different Tag name?

  12. Hi Dave,

    Thanks to you and the Google Team for Google App Inventor. Great idear, letting us normal individuals to run our own idears without having any knowledge of programming – It will give space to a lot of entrepreneurs, like myself to do great thinks on the android platform – I saw the seminar from Copenhagen, where one of directors/chief engineers told about the 10-15 years future-apps and superfast computers and the way we are going to livewith them…Realy exiting…

    I have studied App Inventor in almost 3 weeks now – and I’m a little bit proud, what I have achieved. Both funny- and usefull apps on my HTC Legend – A pitty that for the time beeing it only can be used by yourself, since you can’t upload them to The Android Market yet – hope you will be able to do that very soon – when, if I may ask? 🙂

    Now I going into the API’s, making WebDB’s that can interact with my apps on my phone – I got a lot of idears. I have created my own appspot on the Google appspot server – but having some trouble that I can’t solve because I’m onlys an a “inventor” type not a programmer.

    I’m trying to Deploy The SampleDatabase you gave us into my account on appspot.com but I retrive this:
    2011-02-25 22:53:44 Running command: “[‘C:\\Python30\\pythonw.exe’, ‘-u’, ‘C:\\Program Files\\Google\\google_appengine\\appcfg.py’, ‘–no_cookies’, u’–email=gyldenapps@gmail.com’, ‘–passin’, ‘update’, u’C:\\WebDB\\appinventordb’]”
    Traceback (most recent call last):
    File “C:\Program Files\Google\google_appengine\appcfg.py”, line 71, in
    run_file(__file__, globals())
    File “C:\Program Files\Google\google_appengine\appcfg.py”, line 67, in run_file
    execfile(script_path, globals_)
    NameError: global name ‘execfile’ is not defined
    2011-02-25 22:53:44 (Process exited with code 1)
    You can close this window now.

    What seems to be wrong – I have neither succeded to run the service, local on my computer when I have unziiped the file??

    Hope you got time to help my with some simple explaining for non prgrammeurs like myself

    Thanks for your time – I’m enjoying your tutorial vidoes which I’m buying and downloading with pleasure

    ClausG from Denmark

  13. How do you make it so when someone visits your Appspot url directly they have to login. I have spent a few hours going over Google’s documentation here:

    There are easy ways to do it but they all block my app from accessing the App Engine App also? They way it is now someone could just click delete and break my apps.

    • Hi David. I have some notes on app inventor account management, check out:


      I think the key is that, in the app.yaml file, you can set the permissions for particular requests/pages. So the request from the mobile client (getvalue?) could be set so as to not require a password.

      Hope this helps.


      • Hi,
        I started using appInventor. I am able to design the Textboxes and Buttons and program them using the blocks. but when I need a TinyDB I am unable to set the properties like url AND ID. could you help me with that. the appinventor properties area is blank.

        Have a good weekend

      • Hi Manmohan. Are you trying to connect to an API– a data source on the web? If so, are you using the TinyWebDB component instead of the TinyDB component (TinyDB is for storing persistent data from your app to a DB on the device).

        If you are using TinyWebDB, you want to set the ServiceURL property to the URL of the data source you want to talk to. For instance, I’m an app that gets data from http://yahoostocks.appspot.com, so I set my TinyWebDB.ServiceURL property to that.

        Hope this helps,


  14. Wow thanks. I just now found your reply after all this time.

    Anyway, I still haven’t figured out how the app can store and get values from the app without allowing access to browsers.

    The issue is the delete buttons that came with your source code. Can I make it so no one sees anything if they go to the url?

    I enabled debugging and data storage management on the admin panel and can add or remove from there it looks like.

    On a different page on your site I asked you if you have checked out the new App Engine Backend service. It looks awesome. http://www.youtube.com/watch?v=-kepYfCBg6w

    Anyway I appreciate all your help and I made some cool apps with your system. I have one with 50,000 downloads already.

    BTW: When I enabled debugging I started seeing errors in the admin for the apps I made. They are really long but they end with:

    A serious problem was encountered with the process that handled this request, causing it to exit. This is likely to cause a new process to be used for the next request to your application. If you see this message frequently, you may be throwing exceptions during the initialization of your application. (Error code 104)

  15. BTW: You can add DataStore Viewer by adding the following code to your app.yaml file:

    – datastore_admin: on

  16. Hello,

    I would like to know how to display on the phone multiple value for a same tag:

    for example, on my dictionary I have:

    tag value
    allumer to fire
    allumer to light
    allumer to switch_on

    today, when type “allumer” I only got in response: “to fire”

    Is it possible within the app inventor block editor to do to something to display these 3 value on the phone ?


  17. I have been trying to load a csv file for the past week. I have modified the code and I receive only ssl warnings. The data however does not get updated in the TinyWebDB. Is there a way to debug the Main.py by stepping through or breaking when it encounters an error and reporting the error condition.

    • Hi Joe. I don’t think there’s a debugger for app engine (appspot) apps. The dashboard on appspot does report errors that occur and the line #s in the Python code, but it looks like you’re already on to that.

      BTW, app inventor provides an alternative now to tinywebdb– you can communicate with fusion tables, Google’s beta cloud persistent data.

      good luck,


      • Thanks for the information and the quick reply.

        I have been looking at the Fusion Tables.

  18. Also, I think the team did a great job and should be commended on the time they spend answering questions from the masses.

    Thank you all.

  19. Hi, I just purchased your book in kindle format, thanks for the tutorials and a well written book. I have two questions 1How can I check if a value is already stored in a TinywebDB ? and its possible to store multiple arguments for one Tag at different time intervals ?(e.g.I save TAG 1, 2 and 3 right now it saves as an argument the current time of the system, then a few minutes or hours later I Save TAG 1,2 and 3 again and it puts a new a timestamp without overwriting the previous stored valued is this possible ? so at the end of the day if I check the Database I can have something like this Tag 1 (Time1, Time2, Time3, etc) for each stored value.

    Thanks once again for your tutorials.


    • Hi Nicolas. Here are some quick answers to your questions:

      1. How can I check if a value is already stored in a TinywebDB ?

      The only way to check for a value in the web db is to call TinyWebDB.getValue(tag). If there is no data value for the tag you send, the result in TinyWebDB.GotValue will be the empty string. You can check this by checking if the length of result is greater than 0.

      2. is it possible to store multiple arguments for one Tag at different time intervals ?(e.g.I save TAG 1, 2 and 3 right now it saves as an argument the current time of the system, then a few minutes or hours later I Save TAG 1,2 and 3 again and it puts a new a timestamp without overwriting the previous stored valued is this possible ? so at the end of the day if I check the Database I can have something like this Tag 1 (Time1, Time2, Time3, etc) for each stored value

      Tinywebdb only stores one value for each tag. You can store a list as a value, however. So you could store different timestamps in a list, and store the entire list as a value of some tag. To implement this scheme, you need to load the list into your app using GetValue. Then call add item to list to add a new item (time stamp) to the list, then remember to call TinyWebDB.StoreValue to put the updated list back into the database.

      For examples of storing lists of data using tinywebdb, check out the MakeQuiz/TakeQuiz sample chapter (ch 10), as well as the Database chapter (ch 22)

      • Thank you so much, it works. Sorry to bother you with two other questions :
        1. This one is more a python PHP question and sorry about that, my programming knowledge is very limited, how can I put a Download info as a CVS button in the appinventorDB file ?

        2. How can I send a stored tinyDB list from my phone in cvs format ?

        Thanks again for your help.


      • Hi Nico. Do you mean CSV (comma-separated values)? Do you want the app user to be able to download a csv file?

        For #2, check out the list component, I think there is a way to convert back and forth from csv to list data.


  20. Yes I meant CSV, sorry about that. I want to be able to put in my custom URL http://mywebdb.appspot.com/ PHP file a code that will display a button that will allow the user of the online database file to download all current stored data as a CSV, again I know this is not app inventor related question more a PHP python question but any help or guidance on how to do this I would really appreciate it.

    For 2# I was able to convert a list to a CSV for info stored in a tinydb, I just need to send this info via e-mail using the activity starter.

    Dave, one last question do you know if NFC support is coming to app inventor?

    Thanks for all your help, probably I will keep bothering you with questions. :).



  21. how would I handle app authentication to the app engine service?
    ie- i want my app and ONLY my app to be authenticated to access the app engine service.

  22. Hi all,
    I have not recieved the key for confirmation and i cant carry on.

    I am stuck at this step https://appengine.google.com/permissions/smssend
    Even after asking for the key many times and waiting for hours I have not got the code .
    Please help.

  23. I do see the code “url: .* script: main.py”. I’m afraid I’m a newbie when it comes to using GAE. What should the reference be? Also the application is “lptinydb”. Thanks for your help.. Don

  24. […] that even this has a limited time because only 250 items are stored and older items are lost. See https://appinventorapi.com/program-an-api-python/ for the details of how to do that. This entry was posted in Uncategorized. Bookmark the […]

  25. Hi there, just started app inventor last week, having some really good progress, very easy and useful software. Just have 1 question, the tinywebdb, when I create a custom service for tinywebdb it starts on a free setting basis with google app engine, but its very limitting, obviously for personal use only, I’m building an app for our church and I think the free google app engine won’t last as free once the app is in full activity, and the google billing fees are kinda *scary* so I’m asking if its possible that I can setup my own web server that can fit with the tinywebdb component of app inventor. If yes, can you send give any documents on how to make this possible. This could really help.

    Hope to hear from you soon, thanks!

    • Hi Jo. Good question. The google appengine billing fees aren’t bad. Its free until you reach some thresholds. Those aren’t too high, but if you do then enable billing, you can set it to limit at something as low as $2 a week. Those thresholds are actually pretty high.

      The other way to go, and I don’t have as much experience with this, is to store your data in a google fusion table. There is a component for that in app inventor.

      Hope this helps,


  26. Hello together,
    very nice and helpful postings here.
    I have the same problem as “ClausG, on February 25, 2011 at 10:22 pm” and I didn’t find a answer at all.
    I did the tutorial exactly the way it is described but at the time I ran it with Google AppEngine Launcher I got the following log:

    2013-04-24 10:20:30 Running command: “[‘C:\\Python33\\python.exe’, ‘C:\\Program Files (x86)\\Google\\google_appengine\\dev_appserver.py’, ‘–skip_sdk_update_check=yes’, ‘–port=8080’, ‘–admin_port=8000’, ‘C:\\Users\\Lukas\\Downloads\\toatourdates’]”
    Traceback (most recent call last):
    File “C:\Program Files (x86)\Google\google_appengine\dev_appserver.py”, line 193, in
    _run_file(__file__, globals())
    File “C:\Program Files (x86)\Google\google_appengine\dev_appserver.py”, line 189, in _run_file
    execfile(script_path, globals_)
    NameError: global name ‘execfile’ is not defined
    2013-04-24 10:20:30 (Process exited with code 1)

    Have I installed the wrong Python version or anything like that. I checked the app.yaml and the dev_appserver.py but my experiences with Python aren’t so well.
    Can anyone help me please.
    I have to write an app for my study 😉

  27. I’m having the same problem as Lukas and ClausG. Is there anybody with a solution?

  28. Just checked my Python version – perhaps might have been an idea to do this before the install !! Anyway, my version is 3.2.3. I noticed during the app engine install that it required version 2.7.X is this the problem?

  29. This may not be the correct forum for this problem but I can’t think of anywhere else! I’ve tried setting this up but my problem seems to lie with Creating the Application in Google App Engine. I have selected a unique name but after clicking on the create button it returns me to the welcome screen. When I go back in and try again it knows the ‘name’ has been used so warns me it’s not unique. When I try and access the URL i.e. http://www.shstanselms.appspot.com I get a 500 server error back. When I try to deploy I get an (404) error stating that the application: shstanselms does not exist. What is happening?

  30. Hello, Good Evening Mr. Wolber or every person will can help me.
    I hope to catch your attention.
    I from Spain,and I stady app inventor. Afther going whith tinyweb, I would like resolve this problem with tinyDb:

    Problem with TinyDB.
    I’m reading the book App Inventor, which helps me understand and advance my learning from my house alone with her book. I have reached a difficult point , and after looking at it a lot I have seen the error , I just do not fix it.
    I attach a file from my work learning .
    I make a very simple application to collect customer name , store them in a database and display it in a label .
    It happens that everything works right, but when you exit the application and re-enter , the saved data is displayed in the label as I ask the application to do so. When writing a new customer, the previous data is gone and can not accumulate new customers with already saved , I deleted the above and save news.I thik, this is because the variable, retrieves data from the database , but typing the new name , delete the old list and add new ones.
    How I can do that always persist the data, and to save the new old join ?
    I hope please read my post and can help me.
    Thanks and Regards
    Eduardo martinez

  31. Just an FYI. If someone is seeing an error like this:

    from django.utils import simplejson as json
    ImportError: No module named django.utils

    Changing line 14 in main.py from:
    from django.utils import simplejson as json

    import json

    Will resolve the problem. This is occuring due to the change from Python 2.5 to 2.7 in the current versions of GoogleAppEngine.

  32. Hi
    what i need to Change in the app.yaml file?where to write the application identifier

    “application: appinventordb
    version: 1
    runtime: python
    api_version: 1

    – url: /images
    static_dir: images

    – url: .*
    script: main.py”


  33. hi
    congratulations for all the work done, very useful!
    I have a question to ask you … I do not know if you can only create tables (in myapp.appspot.com) with only three columns like this (Key | Value | Created (UTC)) or if I can create a table to my liking !
    and then I want to know if this service has limits or not?
    I can enter all the data I want?

    I hope I explained, my English is not good because I translate from Italian by Google ..


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: