= 2. Model & Data import = == 2.1 Model explained == [[Image(model2.png, 551px, align=right)]] 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 [https://github.com/django-extensions/django-extensions 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 = '[.gz] [[.gz]]' # -m = name of the dataset # -g = your name # -e = your email address $ ./manage.py import_kismet [] -m -g -e }}} When importing Droidstumbler's .csv: {{{ # args = '[.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...] -m -g -e -d }}} 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 -m -g -e -a -k }}} 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 }}} [[BR]] [[BR]] Time to get the application running; [wiki:running Running the application]