psycodict.validation

What psycodict will put into a statement.

Almost all of psycodict’s SQL is composed from bound placeholders and quoted identifiers, which are safe whatever the values are. The exceptions are the things PostgreSQL has no placeholder for – a column type above all – which have to be interpolated as SQL text. This module is where those are checked, in one place, so that the rule is the same wherever the value came from: a caller, the header of a data file, or a row of a meta_* table that something else edited. Alongside them sit the identifier rules: what names psycodict will create, and how it derives the name of a companion table or a _tmp index from one it was given.

Nothing here touches a connection: every function takes a value and returns the spelling to emit, or raises.

exception psycodict.validation.InvalidColumnTypeError[source]

Bases: ValueError, RuntimeError

Raised for a column type psycodict will not put into a statement.

A ValueError, since an unusable type is a bad argument, and also a RuntimeError, which is what psycodict raised for an invalid type before 1.0.0 and what existing callers may catch.

exception psycodict.validation.InvalidDefinitionError[source]

Bases: ValueError

Raised for an index or constraint definition psycodict will not build DDL from, whether it came from a caller, a metadata file or a meta_* row.