sq inspect inspects metadata (schema/structure, tables, columns) for a source,
or for an individual table. When used with
--json, the output of
sq inspect can
be fed into other tools such as jq to enable complex data pipelines.
Let’s start off with a single source, a Postgres Sakila database:
# Start the Postgres container $ docker run -d -p 5432:5432 sakiladb/postgres:12 # Add the source $ sq add postgres://sakila:p_ssW0rd@localhost/sakila --handle @sakila_pg @sakila_pg postgres sakila@localhost/sakila
sq inspect @sakila_pg to inspect the source. This output includes the source
metadata, and the schema structure (tables, columns, etc.).
$ sq inspect @sakila_pg
To see more detail, use the
-v) flag with the
To see the full output, use the
-y) flag. YAML has the advantage
of being reasonably human-readable.
sqto introspect the schema.
-j) format renders the same content as
--yaml, but is more
suited for use with other tools, such as jq.
Here’s an example of using
sq with jq to list all table names:
$ sq inspect -j | jq -r '.tables | .name'
See more examples in the cookbook.
Sometimes you don’t need the full schema, but still want to view the source
metadata. Use the
-O) mode to see just the top-level metadata.
This excludes the schema structure, and is also much faster to complete.
Well, that’s not a lot of detail. The
--yaml output is more useful:
--json format produces similar output.
--dbprops mode displays the underlying database’s properties, server config,
and the like.
$ sq inspect @sakila_pg --dbprops
--json to get the properties in machine-readable
format. Note that while the returned structure is generally a set of key-value
pairs, the specifics can vary significantly from one driver type to another.
--dbprops from a SQLite database (in
In additional to inspecting a source, you can drill down on a specific table.
$ sq inspect @sakila_pg.actor
--verbose mode for more detail:
And, as you might expect, you can also see the output in
--dbpropsflags apply only to inspecting sources, not tables.