Database Reference
In-Depth Information
Backing up the Bestaurants_Web geodatabase
Earlier in this chapter, you acquired certain programming skills to help you work with
geodatabases using Python. You will now use these skills to write a full script for a new as-
signment. Going back to our Belize client and the Bestaurants project, the geodatabase you
created is growing and is becoming rich. It has reached a stage where it is ready to be pub-
lished on the Web to be accessed by mobile. However, before doing that, the geodatabases
have to be frequently backed up and some changes have to be made to the schema. The cli-
ent asked you to create a new geodatabase called
Bestaurants_Web
, which is a lighter
version of the geodatabase so it can be accessed swiftly. They suggested to remove some
fields and the reviews. This geodatabase should be updated on a daily basis and a daily
backup of the geodatabase should be kept, labeled by the date.
This is obviously a tedious job to be done manually. Therefore, we will use Python to help
us in this assignment. According to the client, the
Bestaurants_Web
geodatabase
should have only one feature class, named
Restaurants
, and no reviews or attachments.
The following fields should be in the
Restaurants
table:
Field Name
Field Type
NAME
Text
WEBSITE
Integer
CATEGORY
Integer
We will break this assignment into three parts. First, we need to create the
Bestaur-
ants_Web
geodatabase. Second, we need to copy the
Food_and_Drinks
feature class
to the new geodatabase, and finally, we need to delete unwanted fields from the new fea-
ture class. The client also asked to create a daily backup of the
Bestaurants_Web
geodatabase, so our script should take care of that as well. This is an iterative process. We'll
build the code piece by piece before saving and running the whole thing:
1. Create a new folder named
Web
under the
c:\gdb
folder.
2. Open a new Python editor session, save the file as
Web_Bestaurants.py
un-
der the
scripts
folder, and let's start by creating a new
Bestaurants_Web
geodatabase. You should know how to create a file geodatabase by now: