wiki:model_data

Version 5 (modified by dennisw, 13 years ago) ( diff )

--

2. Model & Data import

2.1 Model explained

The image on the right shows the model defined in gheat/models.py

This model is used for saving all the collected data. There is a table Meting which contains the lats & lons, signal strength, and 2 foreign keys which refer to Accespoint, where all the accespoint data is saved, and Meetrondje, a table defining datasets. Meetrondje has again 2 foreign keys, one to Gebruiker where the name and email address is saved of the person who owns the dataset, and one to Apparatuur where device information will be stored.

NOTE : The image is generated by installing django_extentions and the command: ./manage.py graph_models gheat | dot -Tpng -o model.png.

2.2 Preparing the database

The model may exist in the gheat/ folder, but it doesn't exist in your database yet. You can use the following command to sync the database.

$ ./manage.py syncdb

# Some other handy commands are:
$ ./manage.py sql gheat  # This prints the sql output from the models file that will be used for creating the tables
$ ./manage.py flush  # This flushes the database, leaving the tables intact but empty

Remember that when you have edited the models, you have to run the syndb command to make the changes effective in your database.

2.3 Data import

When importing Kismet's .gpsxml and .netxml:

# args = '<gpsxml>[.gz] [<netxml>[.gz]]'
# -m = name of the dataset
# -g = your name
# -e = your email address

$ ./manage.py import_kismet <gpsxml> [<netxml>] -m <dataset name> -g <username> -e <email>

When importing Droidstumbler's .csv:

# args = '<csvfile>[.gz] [csvfile2[.gz] [csvfile3[.gz] ...]'
# -m = name of the dataset
# -g = your name
# -e = your email address
# -d = date in %Y-%m-%d-%H%M%S format, default takes date from filename

$ ./manage.py import_droidstumbler <csvfile> [csvfile...] -m <dataset name> -g <username> -e <email> -d <date>

When importing other .csv files:

# Make sure the variables in this script match the column numbers in your file e.g.;
# Lat is read from the first column [0], if the lat in your file is in the 4th column, change 'lat = row[0]' to 'lat = row[3]'.
# Also, take note of the replace() and strip() functions. These should probably be edited aswell.
#
# -f = location of the .csv
# -m = name of the dataset
# -g = your name
# -e = your email address
# -a = antenna
# -k = network card

$ ./manage.py import_csv -f <file location> -m <dataset name> -g <username> -e <email> -a <antenna> -k <network card>

If you would like to add random points to the database, you can run the gheat/management/commands/add_random_points.py:

$ ./manage.py add_random_points -c <number of points>



Time to get the application running; Running the application

Attachments (2)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.