See prepared SQL statement and/or database tracing?

In the project I’m working on, database queries that were run are saved to a different database. Presently, the statements are prepared manually, but that allows for the exact query to get stored as a log of sorts

Is there a way to update this to prepared statements (runPrepQuery) and get the compiled statement easily? Is there any sort of tracing available?

Thanks

I’ve always used the database’s own ability to log queries.

2 Likes

You can also set the Gateway.Database.Updates (or Selects) loggers to TRACE to get every database event that’s going through Ignition’s connection pooling. On a busy system, that can obviously be quite a lot.

2 Likes

I’m terrible at making these questions smh

When storing the queries that were sent to the database, the user information is stored as well, which is the beauty of this method… INSERT INTO queryLog (userName, query) kind of thing. So while using the database’s built in method would normally be my go-to, since Ignition is just one user to the database this method makes sense

I just wish I could get us off of manually preparing queries. Perl’s DBI module, for instance, has a method to show you the specific trace event for the latest query you ran with your DBI object. It’s part of what gets returned

Thanks

You might want to consider using Ignition’s built in auditing. It stores all the information you are looking for plus a whole lot more. Following is a link to the documentation: https://docs.inductiveautomation.com/display/DOC79/Using+Audit+Profiles