This functionality has already been built into Pulp 2.4 with the addition of the --generate-sqlite flag for repos. This is an optional flag due to the amount of time that is required to generate the sqlite files.