piicatcher icon indicating copy to clipboard operation
piicatcher copied to clipboard

sqlalchemy.orm.exc.NoResultFound: No row was found for one()

Open yourssvk opened this issue 2 years ago • 2 comments

Problem description:

If I run detect on a Redshift database with a new catalog db specified for the run, it returns this:

piicatcher --catalog-host localhost --catalog-port 5432 --catalog-user piicatcher --catalog-password --catalog-database piicatcher_1 detect --source-name --scan-type metadata --include-schema

Traceback (most recent call last): File "/home/ec2-user/.env/bin/piicatcher", line 8, in sys.exit(app()) File "/home/ec2-user/.env/lib64/python3.7/site-packages/typer/main.py", line 214, in call return get_command(self)(*args, **kwargs) File "/home/ec2-user/.env/lib64/python3.7/site-packages/click/core.py", line 1128, in call return self.main(*args, **kwargs) File "/home/ec2-user/.env/lib64/python3.7/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/home/ec2-user/.env/lib64/python3.7/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/ec2-user/.env/lib64/python3.7/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/ec2-user/.env/lib64/python3.7/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/home/ec2-user/.env/lib64/python3.7/site-packages/typer/main.py", line 500, in wrapper return callback(**use_params) # type: ignore File "/home/ec2-user/.env/lib64/python3.7/site-packages/piicatcher/command_line.py", line 196, in detect source = catalog.get_source(source_name) File "/home/ec2-user/.env/lib64/python3.7/site-packages/dbcat/catalog/catalog.py", line 191, in get_source .filter(CatSource.name == source_name) File "/home/ec2-user/.env/lib64/python3.7/site-packages/sqlalchemy/orm/query.py", line 3500, in one raise orm_exc.NoResultFound("No row was found for one()") sqlalchemy.orm.exc.NoResultFound: No row was found for one()

Expected Result;

A new db with all the required metadata tables gets created for the scan to happen (if the table does not exist already)

yourssvk avatar Feb 11 '22 09:02 yourssvk

Can you run add_redshift command?

https://tokern.io/docs/piicatcher/#command-line-usage

I'll keep this issue open to improve the error message

vrajat avatar Feb 11 '22 10:02 vrajat

Also it is better to specify the catalog information in a config file.

https://tokern.io/docs/catalog/configuration#config-file

vrajat avatar Feb 11 '22 10:02 vrajat

@yourssvk - Still facing the issue? Can you please try and let me know if issue still persist!

yjagdale avatar Dec 12 '22 10:12 yjagdale

Meanwhile improved error message.

yjagdale avatar Dec 12 '22 11:12 yjagdale

@yjagdale not in a position to test this at this point. Please feel free to close

yourssvk avatar Dec 12 '22 12:12 yourssvk

Thanks for the issue @yourssvk. Tested at my end and working as expected. Also improved error message for the same.

yjagdale avatar Dec 13 '22 06:12 yjagdale