| 34 | | |
| 35 | | Make sure `modules/s3gis.py` containing `utf8_csv_reader()`, which is included since [http://bazaar.launchpad.net/~flavour/sahana-eden/trunk/revision/1413 rev1413]. Place `L1.csv, L2.csv, L3.csv` in the top level of `web2py` directory. |
| 36 | | |
| 37 | | {{{ |
| 38 | | >>> tablename = "gis_location" |
| 39 | | >>> table = db[tablename] |
| 40 | | # Example to look for a record's id |
| 41 | | >>> db(table.name == "Taiwan").select().first().id |
| 42 | | 215 |
| 43 | | # L0 |
| 44 | | >>> db(table.name != "Taiwan").delete() |
| 45 | | # Here will show the number of deletion |
| 46 | | >>> db.commit() |
| 47 | | # L1 |
| 48 | | >>> gis.import_csv("L1.csv") |
| 49 | | >>> db.commit() |
| 50 | | # L2 |
| 51 | | >>> gis.import_csv("L2.csv") |
| 52 | | >>> db.commit() |
| 53 | | # L3 |
| 54 | | >>> gis.import_csv("L3.csv") |
| 55 | | >>> db.commit() |
| 56 | | # Example to look for records matching a name |
| 57 | | >>> db.executesql("SELECT * FROM gis_location WHERE name = 'ε
εΎ©ι' and level = 'L3'") |
| 58 | | # Here will show a list of 13 tuples. Use SELECT count(*) in the above statement to verify. |
| 59 | | }}} |
| 60 | | |