FAAImport - diggybell/piaware-tools GitHub Wiki

Table of Contents

FAA Registry Import

Description

This utility can be used to create the SQL scripts required to create and update a copy of the FAA Registry database. This database is updated every business day and is available for download. The database can be retrieved from this address.

https://registry.faa.gov/database/ReleasableAircraft.zip
This will retrieve ReleasableAircraft.zip to your computer. This file should be uncompressed using this command.
unzip ReleasableAircraft.zip

Usage

This utility can be run manually using the following commands

cd <path to piaware-tools>/utility
php faa-update.php <options>
The output from the utility will come to the screen by default. This output can either be redirected to a file, or passed to the MySQL/MariaDB command line utility. Both of these methods are shown below.

Redirect to File

php faa-import --truncate --import --directory=<path to faa data> --file=MASTER.txt > master.sql
mysql faa < master.sql

Pass to MySQL/MariaDB Command Line Utility

php faa-import --truncate --import --directory=<path to faa data> --file=MASTER.txt > mysql faa

Initial Database Creation

Using the methods described above, you will need to populate the initial database using data from three of the files contained in the FAA registry download. These files are listed below.

  • MASTER.txt
    • This file contains the master N-Number registration data
  • ACFTREF.txt
    • This file contains the list of aircraft models
  • ENGINE.txt
    • This file contains the list of engine models
There are a number of command line options available to control execution of this program.

Options

  • --schema
    • Generate SQL to define tables based on FAA source data
      • REQUIRED the first time to create the database on your MySQL/MariaDB installation
  • --import
    • Generate SQL to import from FAA source data
  • --truncate
    • Generate SQL to truncate the table (ignored with --schema)
  • --directory=<dir>
    • Directory containing FAA source data
  • --file=<filename>
    • The name of the file to import (case sensitive)
  • --help
    • Display this help

CRON Automation

This utility should be integrated with CRON to provide a daily update of the FAA database. The following example will execute the script at 02:00 to update the Master, Aircraft Reference, and Engine tables.

# download the current faa database and extract files
30 1 * * * cd <path to faa data>; wget https://registry.faa.gov/database/ReleasableAircraft.zip; unzip -j ReleasableAircraft.zip
# import the master icao/n-number table
0 2 * * * cd <path to piaware-tools>/utility; php faa-import --truncate --import --directory=<path to faa data> --file=MASTER.txt > mysql faa
# import the aircraft reference data
0 2 * * * cd <path to piaware-tools>/utility; php faa-import --truncate --import --directory=<path to faa data> --file=ACFTREF.txt > mysql faa
# import the engine reference data
0 2 * * * cd <path to piaware-tools>/utility; php faa-import --truncate --import --directory=<path to faa data> --file=ENGINE.txt > mysql faa
Notes:
  1. Replace <path to piaware-tools> with the base path where you installed PiAware Tools.
  2. Replace <path to faa data> with the path where you have stored the FAA Registration data
⚠️ **GitHub.com Fallback** ⚠️