diff --git a/plugins/python/parser/include/pythonparser/pythonparser.h b/plugins/python/parser/include/pythonparser/pythonparser.h index b3b1c25d8..79ce39ea3 100644 --- a/plugins/python/parser/include/pythonparser/pythonparser.h +++ b/plugins/python/parser/include/pythonparser/pythonparser.h @@ -26,6 +26,7 @@ class PythonParser : public AbstractParser PythonParser(ParserContext& ctx_); virtual ~PythonParser(); virtual bool parse() override; + virtual bool cleanupDatabase() override; private: struct ParseResultStats { std::uint32_t partial; diff --git a/plugins/python/parser/src/pythonparser.cpp b/plugins/python/parser/src/pythonparser.cpp index f52c8703b..3f3125b43 100644 --- a/plugins/python/parser/src/pythonparser.cpp +++ b/plugins/python/parser/src/pythonparser.cpp @@ -182,6 +182,19 @@ bool PythonParser::parse() return true; } +bool PythonParser::cleanupDatabase() +{ + LOG(info) << "[pythonparser] Incremental parsing unsupported, cleaning up previous analysis results from database ..."; + odb::connection_ptr connection = _ctx.db->connection(); +#ifdef DATABASE_PGSQL + connection->execute("TRUNCATE TABLE \"PYName\";"); +#else + connection->execute("DELETE FROM \"PYName\";"); +#endif + LOG(info) << "[pythonparser] Cleanup finished!"; + return true; +} + PythonParser::~PythonParser() { }