How to use the piicatcher.explorer.sqlite.SqliteExplorer function in piicatcher

To help you get started, we’ve selected a few piicatcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tokern / piicatcher / tests / test_sqlite.py View on Github external
def test_sqlite_dispatch(self):
        with mock.patch(
            "piicatcher.explorer.sqlite.SqliteExplorer.scan", autospec=True
        ) as mock_scan_method:
            with mock.patch(
                "piicatcher.explorer.sqlite.SqliteExplorer.get_tabular", autospec=True
            ) as mock_tabular_method:
                with mock.patch(
                    "piicatcher.explorer.explorer.tableprint", autospec=True
                ) as mock_table_print:
                    SqliteExplorer.dispatch(
                        Namespace(
                            path="connection",
                            list_all=None,
                            catalog={"format": "ascii_table"},
                            scan_type=None,
                            include_schema=(),
                            exclude_schema=(),
                            include_table=(),
                            exclude_table=(),
                        )
                    )
                    mock_scan_method.assert_called_once()
                    mock_tabular_method.assert_called_once()
                    mock_table_print.table.assert_called_once()
github tokern / piicatcher / tests / test_sqlite.py View on Github external
def temp_sqlite(request, tmpdir_factory):
    temp_dir = tmpdir_factory.mktemp("sqlite_test")
    sqlite_path = temp_dir.join("sqldb")

    explorer = SqliteExplorer(
        Namespace(
            path=sqlite_path,
            catalog=None,
            include_schema=(),
            exclude_schema=(),
            include_table=(),
            exclude_table=(),
        )
    )

    request.cls.explorer = explorer
    request.cls.path = str(sqlite_path)

    def finalizer():
        explorer.get_connection().close()
        rmtree(temp_dir)
github tokern / piicatcher / tests / test_databases.py View on Github external
def test_sqlite(self):
        self.assertEqual(
            'select "c1","c2" from t1',
            SqliteExplorer._get_select_query(
                self.schema,
                self.schema.get_children()[0],
                self.schema.get_children()[0].get_children(),
            ),
github tokern / piicatcher / piicatcher / explorer / sqlite.py View on Github external
def __init__(self, ns):
        super(SqliteExplorer, self).__init__(ns)
        self.path = ns.path
github tokern / piicatcher / piicatcher / explorer / sqlite.py View on Github external
def _get_context_manager(self):
        return SqliteExplorer.CursorContextManager(self.get_connection())
github tokern / piicatcher / piicatcher / explorer / sqlite.py View on Github external
def factory(cls, ns):
        logging.debug("Sqlite Factory entered")
        return SqliteExplorer(ns)
github tokern / piicatcher / piicatcher / explorer / sqlite.py View on Github external
exclude_table=exclude_table,
    )

    if output_format is not None or output is not None:
        logging.warning(
            "--output-format and --output is deprecated. "
            "Please use --catalog-format and --catalog-file"
        )

    if output_format is not None:
        args.catalog["format"] = output_format

    if output is not None:
        args.catalog["file"] = output

    SqliteExplorer.dispatch(args)