Fix some import issues.
Allow tests to be run against postgres.
Remove old print statements.
Fix rating query to work against postgres and sqlite.
Fix another rating query to work against postgres and sqlite.