Skip to main content
Ready-made query sets for common database engines. Each section below provides a JDBC connection string and capability queries you can paste into the Database connector configuration, then adapt to your environment.

How to use these examples

  1. Copy the queries for the capabilities you need. At minimum, Validate Credentials and List Accounts.
  2. Adapt table names, columns, and status logic to your environment. The engine-account queries work as-is against system catalogs. Application-database queries always need adapting to your schema.
  3. Strip comments and flatten each query to a single line before pasting. Lumos does not support comments in SQL queries. On macOS, this flattens your clipboard:

Sample Application Database

A complete worked example of governing a custom application through the Database connector, using a sample schema in Microsoft SQL Server. It demonstrates the read and write capabilities except List Updated Accounts and Update Account. In production, your application has its own schema and column names, which you model the same way.

Schema

The sample models identity data the way most applications do: an accounts table, a resources table, an entitlements table, a join table for assignments, and an activity log.
A Python generator script populates the schema with realistic sample data (200 users, 10 resources, 20 entitlements by default, with industry-standard status distributions). Install its dependencies with pip install pyodbc faker tqdm and run it with your server, database, and credentials.
lumos_generator.py
Run these queries to confirm the tables, account distribution and entitlement associations.

Sample connection string

Sample read capabilities

Validate Credentials
List Accounts
Get Account
List Entitlements
Find Entitlement Associations
Get Last Activity
List Resources

Sample write capabilities

Create Account (the SELECT goes in the Create Account Return ID field)
Activate Account
Deactivate Account
Delete Account (a soft delete, preserving referential integrity)
Assign Entitlement
Unassign Entitlement

Microsoft SQL Server

Discovers server logins and per-database users with their role memberships, across all databases on the instance via dynamic SQL.

SQL Server connection string

SQL Server List Accounts

Unions server principals (logins) with each database’s principals, identifying accounts as name@server or name@database:
Validate Credentials is the same query wrapped to return one row: replace the final EXEC(@SQL); with SET @SQL = 'SELECT TOP 1 * FROM (' + @SQL + ') AS AllResults;'; EXEC(@SQL);

SQL Server List Entitlements

Server roles plus each database’s roles:

SQL Server Find Entitlement Associations

Server role memberships plus each database’s role memberships:

SQL Server List Resources

Using stored procedures

Stored procedures work as long as the final result has the correct column labels. For reads, extract the procedure’s results into a table variable, then SELECT from it with the right aliases:
For writes, call the procedure with the templated field:

Oracle DB

Discovers Oracle accounts and granted roles from the DBA views.

Oracle connection string

Using the SID:
Using the service name:

Oracle List Accounts

Validate Credentials is the same query with WHERE ROWNUM = 1 appended.

Oracle List Entitlements

Oracle Find Entitlement Associations

Oracle versions older than 12.2 limit identifiers to 30 characters. Use integ_specific_entitlement_id and integ_specific_resource_id as the field names in that case.

Oracle List Resources

Oracle write capabilities

Oracle account writes are DDL, so identifiers take the ! suffix (unquoted), while string literals don’t: Create Account
TempPass123 is a placeholder. Replace it with a password that meets your Oracle password policy. Lumos needs the new account’s ID back from Create Account, so also fill in the Create Account Return ID query. Update Account

PostgreSQL

Discovers roles from pg_catalog, mapping login capability and validity to account status.

PostgreSQL connection string

PostgreSQL List Accounts

Validate Credentials is the same query with LIMIT 1.

PostgreSQL List Entitlements

PostgreSQL Find Entitlement Associations

PostgreSQL List Resources


MySQL

Discovers users from mysql.user, plus privileges and roles from information_schema and mysql.role_edges.

MySQL connection string

MySQL List Accounts

Validate Credentials is the same query with LIMIT 1.

MySQL List Entitlements

Schema privileges, roles, and global privileges as three unioned entitlement sets:

MySQL Find Entitlement Associations

MySQL List Resources


MongoDB

Uses the JDBC driver’s shell-syntax queries against the admin database’s system.users and system.roles collections.

MongoDB connection string

MongoDB Validate Credentials

MongoDB List Accounts

MongoDB List Entitlements

MongoDB Find Entitlement Associations

MongoDB List Resources


Snowflake

Discovers users, roles, role inheritance, and effective database, warehouse, and schema access from the SNOWFLAKE.ACCOUNT_USAGE views. Note that a dedicated Snowflake connector also exists in the Integration Library. Use these queries when you want the query-driven JDBC approach instead.

Snowflake connection string

Snowflake List Accounts

Rich account listing with MFA, warehouse, and lock state surfaced as custom attributes:
Validate Credentials is the same shape with WHERE DELETED_ON IS NULL LIMIT 1.

Snowflake List Entitlements

Roles, role-to-role inheritance, and database, warehouse, and schema access grants as five unioned sets:

Snowflake Find Entitlement Associations

Direct role grants, role inheritance, and effective database, warehouse, and schema access through assigned roles:

Snowflake List Resources

Snowflake Get Last Activity


Databricks

Discovers grantees and their catalog, schema, and table privileges from Unity Catalog’s system.information_schema. A dedicated Databricks connector exists in the Integration Library, and Databricks can also connect via Universal REST. Use these queries for the SQL-warehouse approach.

Databricks connection string

Databricks Validate Credentials

Databricks List Accounts

Derives the account list from grantees across all privilege tables:

Databricks List Entitlements

Catalog, schema, and table privileges as three unioned entitlement sets:
Table-level privileges can be numerous. Drop the third UNION block if you only need catalog and schema governance.

Databricks Find Entitlement Associations

Databricks List Resources

Databricks Get Last Activity


Compatible engines without a dedicated example

Many databases are wire-compatible with an example above. Use the matching example and change only the connection string:
  • Azure SQL Database and Azure SQL Managed Instance: use the Microsoft SQL Server queries. Authenticate with a SQL login (username and password). Microsoft Entra ID authentication is not supported.
  • Amazon RDS and Aurora: use the queries for the underlying engine (MySQL or PostgreSQL). IAM database authentication is not supported, so create a native database user.
  • MariaDB: use the MySQL queries.
  • Amazon Redshift and CockroachDB: PostgreSQL-derived. Start from the PostgreSQL queries and verify the catalog views, since system tables differ in places.
  • Google Cloud SQL and AlloyDB: use the queries for the underlying engine.
The rule in every case: Lumos connects with a native database user and password over JDBC, using the driver for the engine you pick in the connector’s Database Type list.