Page 20 -
P. 20
table of contents
manage your data
9 Handling input
The Web and your phone are not just great ways to display data.
They are also great tools to for accepting input from your users. Of course, once your
webapp accepts data, it needs to put it somewhere, and the choices you make when
deciding what and where this “somewhere” is are often the difference between a webapp
that’s easy to grow and extend and one that isn’t. In this chapter, you’ll extend your
webapp to accept data from the Web (via a browser or from an Android phone), as well
as look at and enhance your back-end data-management services.
Your athlete times app has gone national 294
Use a form or dialog to accept input 295
Create an HTML form template 296
The data is delivered to your CGI script 300
Ask for input on your Android phone 304
It’s time to update your server data 308
Avoid race conditions 309
You need a better data storage mechanism 310
Use a database management system 312
Python includes SQLite 313
Exploit Python’s database API 314
The database API as Python code 315
A little database design goes a long way 316
Define your database schema 317
What does the data look like? 318
Transfer the data from your pickle to SQLite 321
What ID is assigned to which athlete? 322
Insert your timing data 323
SQLite data management tools 326
Integrate SQLite with your existing webapp 327
You still need the list of names 332
Get an athlete’s details based on ID 333
You need to amend your Android app, too 342
Update your SQLite-based athlete data 348
The NUAC is over the moon! 349
Your Python Toolbox 350
xviii