USDA makes the FoodData Central database available in CSV and MS Access 2007.
The public domain source files are here.
The importers in this repo can convert USDA CSV to SQLite3.
There are two importers: shell script using Sqlite3 CLI and Python v3.
The fast importer uses the native sqlite3 command line interface to import the files. It uses the autogenerated schema and adds a few indices.
$ sh ./import_fast.sh <dir_of_CSVs> <output_db>
The python importer is about half as fast, but attempts to define a schema. It uses foreign keys when possible and type hinting in Python 3.x.
I had to exclude some foreign keys because the source CSV files appear to have data quality issues.
$ python3 import_food_data.py [-d <dir_of_CSVs>] [-o <output_db] [-f] [-v]
Tested with CSVs from 2019-04-02.
See example queries and TODO for more info.