On this page

Dialect and driver matrix

go.driver chooses the emitter and the driver API generated code calls. The application's Go module must supply that driver. A CLI's linked runtime drivers determine which connections it can open for migrations and introspection.

database/sqlpgxclickhouse (native)
DialectsEvery dialectPostgreSQL familyClickHouse
execresultsql.Result; refused on ClickHousepgconn.CommandTagRefused
batchMulti-row INSERT, or one statement per item for a trailing clauseOne statement per item in pgx.BatchNative batch or multi-row INSERT
copyfromMulti-row INSERT; returns errorCOPY; returns (int64, error)Native batch; returns error
kind: sliceExpands an IN list; ClickHouse uses an Array parameterBinds an array to = ANY($1)Uses an Array parameter
prepared.goWith go.prepared: true, except ClickHouseUnavailableUnavailable
Runtime builderSupportedSupportedSupported
NewWithReplicaSupportedUnavailableUnavailable
WithTx, RunInTxSupportedSupportedUnavailable

The query-command reference defines the required INSERT shapes and COPY type restrictions. Both ClickHouse emitters refuse execrows and execresult (Q059). asyncexec is accepted only on ClickHouse.

Connection settings

MySQL and MariaDB's github.com/go-sql-driver/mysql driver needs parseTime=true in the DSN, for example app:secret@tcp(localhost:3306)/shop?parseTime=true. Generated code scans DATE, DATETIME and TIMESTAMP into time.Time; without that setting the driver returns text and the read fails. The generated package comment records this requirement.

Prepared-statement defaults

go.prepared defaults to false in sgl.yaml. Setting it with pgx, native ClickHouse or database/sql on ClickHouse is a configuration error; ClickHouse's database/sql driver prepares only INSERT statements.

The library's emit_driver_databasesql.New() writes prepared.go by default for compatibility with existing embedded generators. Pass emit_driver_databasesql.WithPrepared(false) to disable it. See emitter selection.