Skip to content

TOML Configuration

Jordan Marr edited this page Dec 17, 2022 · 16 revisions
Name                                                       Required Description
[general] Required This section contains general settings.
connection Required The database connection string
output Required A path to the generated .fs output file (relative paths are valid)
namespace Required The namespace of the generated .fs output file
cli_mutable Optional If this argument exists, a [<CLIMutable>] attribute will be added to each record. Defaults to true.
[sqlhydra_query_integration] Optional This section contains settings that are used when integrating with SqlHydra.Query.
provider_db_type_attributes Optional This field generates metadata attributes used by SqlHydra.Query. Defaults to true.
[readers] Optional This optional section contains settings that apply to generating a HydraReader for your database. (This option should be enabled if you are using the SqlHydra.Query library.)
reader_type Required Generates data readers for each table. You can optionally override the default ADO.NET IDataReader type. Ex: "System.Data.SqlClient.SqlDataReader"
[filters] Optional This optional section applies schema/table filters using globbing patterns.
include Required One or more globbing patterns that specify schemas/tables to include as: "{schema}/{table}"
exclude Required One or more globbing patterns that specify schemas/tables to exclude as: "{schema}/{table}"

Generating TOML File

The SqlHydra CLI will check for a TOML config file. If not found, it will begin a wizard that will create a TOML file for you. Rather than asking you for each individual configuration file, the wizard will only ask for the required options, and then will ask you to select a "use case" for the generated code. The wizard will choose the base options depending on your selected use case.

Use Case Description
SqlHydra.Query Integration (default) This option generates records that include custom integration for use with SqlHydra.Query including metadata attributes and the HydraReader class. You must reference the SqlHydra.Query package when using this option.
Other data library This option is for generating records that can be used with other data access libraries, including Dapper.FSharp, Donald, Npgsql.FSharp, ADO.NET, and many others. Custom attributes and the HydraReader class will be excluded.
Standalone This option generates the table records and the HydraReader but excludes any custom metadata attributes.

This table shows which features are configured for each use case.

  SqlHydra.Query Integration (Default) Other DB Library Standalone Use
Strongly Typed HydraReader ✔️ ✔️
DbProvider Attributes ✔️
Tables Modules ✔️
Functions Modules ✔️
CLIMutable Attribute ✔️ ✔️

Filtering

Generated tables can be filtered by applying globbing patterns supported by Glob.

All filters are case-sensitive!

Table Filters

Include all tables from the dbo schema:

[filters]
include = [ "dbo/*" ]
exclude = [ ]

Exclude all tables from the prod schema:

Note that at least one include is required (includes are applied first, and then excludes are subtracted).

[filters]
include = [ "*" ]
exclude = [ "prod/*" ]

Include all tables that start with "dev" or "test", and exclude tables that contain "123":

[filters]
include = [ "*/dev*", "*/test*" ]
exclude = [ "*/*123*" ]

Column Filters

All column filter patterns must contain a . to separate the table from the column.

Exclude dbo.Person.FName and dbo.Person.LName columns:

[filters]
include = [ "*.*" ]
exclude = [ "dbo/Person.FName", "dbo/Person.LName" ]

Exclude any column in any schema/table that starts with an _.

[filters]
include = [ "*.*" ]
exclude = [ "*._*" ]

Clone this wiki locally