Hamdb FCC Callsign Database Script

Updated 2024-10-15 to fix errors in create database user example.

Updated 2023-10-31 for updated and improved commands.

Updated 2023-10-17 for new FCC file download location, MariaDB, and use of ‘mysqlimport’ rather than ‘load data inline’ which became problematic.

This is a Bourne Shell script that will automagically download the FCC Amateur Radio license database, parse it, and populate a MySQL / MariaDB database. The database can be searched using the command line and is very fast. The download can be put into crontab in order to periodically download a database, so you always have fresh data. The program works on Linux, but undoubtedly works on other flavors of Unix and MacOS.

Instructions

Download the script from Github. Place the hamdb script in /usr/local/bin or your favorite place. Make it executable:

chmod 700 hamdb

If you do not have MySQLVersion 11.13 or better, or MariaDB, download and install it.

Create a database user. Example:

sudo mysql
CREATE USER myusername@localhost IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON *.* TO 'myusername'@localhost;
flush privileges;quit
;

If you do not have wget on your system, download and install (sudo apt install wget). To see if you have it, simply run wget and you will see some help text displayed if you have it. You can also search your hard drive with:

find / -name wget

Run the script:

hamdb full

It will ask you for your database username and password and then create a blank database. The script will then download the database from the FCC, parse it, and store in MySQL / Mariadb.

Run hamdb update to pull a daily update file from the FCC and import it into the database. You can do this any day in order to keep your database the most up to date. If it’s a Monday, the update will pull the Sunday full update and do a full importation. A full importation naturally takes much longer than pulling and importing a daily update.

After the population completes, you can search the database by simply typing hamdb and a callsign like:

hamdb k3ng

To do a wildcard search, do this:

hamdb like k3ng%

The % symbol is a wildcard, much like * is used for file system commands. The command above would find all callsigns beginning with “k3ng”.

You can perform a search for all radio amateurs in a zip code like so:

hamdb zipcode 17701

To search by last name do this:

hamdb lastname Jones

You can also use wildcards with lastname like:

hamdb lastname McD%

To search for former callsigns, search like this:

hamdb former ka3ngh

If you’d like to make hamdb easier to use, you can place an alias in your system profile. I have the following line in /etc/profile: alias h=”/usr/local/bin/hamdb” With this, the “h” command can be used quickly to search such as:

h k3ng

If you have problems with wget, the script can use curl by changing this line to a 1:

USE_CURL_NOT_WGET=1

To get a dump of some database stats do:

hamdb count

If you ever need to remove the database and start fresh do:

hamdb removedb

There is also a help screen that can be viewed with:

hamdb help

Note that if the script has been updated recently this project page may not reflect the latest new commands, however the help screen will most likely be up to date. Documentation is haaaaaard. :-)

If you have a specific search need not covered with the script, please post an inquiry in the Radio Artisan group, with the subject Hamdb.

12 thoughts on “Hamdb FCC Callsign Database Script

  1. Had to change ‘load data infile’ to ‘load data local infile’ (without quotes). Other than that….works great thanks!

  2. hamdb has been trying and retrying the data download for about 45 minutes. I wondered if this had anything to do with it:

    FCC_FILE_LOCATION=https://data.fcc.gov/download/pub/uls/complete//l_amat.zip

    The double-forward-slash after ‘complete’ is odd.

    Any ideas?

    1. Hi Matt. I’ve seen occasionally where the FCC web site is unresponsive. I just clicked on the link and my download completed, 161 MB. The double slash is odd; I’m going to edit that the next update to remove that oddity.

      73

      Goody

      K3NG

      1. Thanks K3NG. I dropped the link into Firefox, and it downloads successfully.

        In Windows 11 WSL2 Ubuntu command line, wget seems to choke. No idea what is going on. Matt, W8MAP

      2. Update: I’m seeing the same behavior you are with wget in Linux. I will investigate later, probably this afternoon. There is something going on….

  3. I’d turn on wget verbosity / debugging to see what wget is trying to do and where it may be getting stuck.

    1. I sent you a reply here with the log of what my system is doing, but it appears that you are seeing the same so you probably don’t need my log info. Thanks for the help!

Leave a reply to Matt Postiff Cancel reply