libpg_query

Parse PostgreSQL SQL queries outside the database server

brewmacoslinux
Try with needOr install directly
Source

About

C library for accessing the PostgreSQL parser outside of the server environment

Examples

extract table names from SQL query$ libpg_query -parse 'SELECT * FROM users WHERE id = 1'
validate PostgreSQL SQL syntax$ libpg_query -parse 'SELECT invalid syntax here'
analyze query structure in JSON format$ libpg_query -parse 'INSERT INTO logs (msg) VALUES ($1)' -format json
check if multiple SQL statements are valid$ libpg_query -parse 'SELECT 1; UPDATE table SET x=1; DELETE FROM y'