TugQL

Query a Git-backed inGitDB repository with TugQL

Read the geo-ingitdb country aliases as a TugQL source and see what a Git-backed adapter must provide.

Inspect the source first

The public geo-ingitdb repository stores records and collection definitions in Git. Its country_aliases collection has alias and country fields. For example, the committed Ireland record maps the alias to ie. A Git repository by itself is not a SQL server; an inGitDB/DALgo adapter must open the data.

Write the read query

databases (
  geo = 'https://github.com/ingitdb/geo-ingitdb'
)
from geo::country_aliases as a
where a.country = 'ie'
select a.alias, a.country

The databases block declares the geo target; geo::country_aliases selects a source from that binding. The target string identifies the repository, but it does not authenticate or mount it. The executing tool resolves that target, supplies an authorized schema, and checks database access policy before reading. See the syntax sheet and source qualifier reference.

Bind and execute

  1. Open the repository with an inGitDB adapter, such as the local Git working-tree DALgo adapter. Its configuration and owner policies apply to reads.
  2. Parse TugQL text and resolve it against the caller-authorized country_aliases schema. The Go tutorial shows the parse/resolve API.
  3. Pass the resolved query to the database binding and execute it under that adapter's read session. Check the returned error and data rather than assuming that every TugQL feature is supported.

For an example that joins this Git-backed database with Chinook, see the cross-database tutorial. QueryDock's current SQL engines do not execute this TugQL query.

All documentation