Crate sqlayout

Source
Expand description

A Library for generating SQLite-specific SQL to Initialize Databases (as in CREATE TABLE...). SQLite Interface agnostic, e.g. can be used with rusqlite, sqlite or any other SQLite Interface.

§xml-config

todo

Structs§

Column
This struct Represents a Column in a Table. It is an Error for the name to be Empty (Error::EmptyColumnName).
ForeignKey
Defines a Foreign Key for a Column. It is an Error for the foreign_table and foreign_column Strings to be Empty (Error::EmptyForeignTableName, Error::EmptyForeignColumnName).
Generated
Defines a Column as Generated. It is an Error for the expr String to be Empty (Error::EmptyGeneratorExpr)
NotNull
Marks a Column as NOT NULL, meaning the Column cannot contain NULL values and trying to insert NULL values is an Error.
PrimaryKey
Marks a Column as a Primary Key. It is an Error to have more than one Primary Key per Table (Error::MultiplePrimaryKeys).
Schema
A Schema (or Layout, hence the crate name) encompasses one or more Tables. Can be converted into an SQL Statement via the SQLStatement Methods. It is an Error for the Schema to be empty ([Error::SchemaWithoutTables]).
Table
Represents an entire Table, which may be Part of a wider Schema or used standalone. Can be converted into an SQL Statement via the SQLStatement Methods. It is an Error for the name to be empty (Error::EmptyTableName) or the Table itself to be empty (Error::NoColumns).
Unique
Marks a Column as “Unique”, meaning the Column cannot contain the same value twice, and trying to insert a value for the second time is an Error.
View
Represents an entire View, which may be Part of a wider Schema or used standalone. Can be converted into an SQL Statement via the SQLStatement Methods. It is an Error for the name to be empty (Error::EmptyViewName) or the Select to be empty (Error::EmptyViewSelect).
ViewColumn

Enums§

Error
Errors for all Structs and Functions in this Crate.
FKOnAction
Reaction to an action on a Column with a ForeignKey See also here
GeneratedAs
Weather a generated column should store its values or compute them on every access
OnConflict
Reaction to a violated Constraint, used by PrimaryKey, NotNull and Unique. See also here
Order
PrimaryKey direction
SQLiteType
Encodes all Column-Datatypes available in SQLite, see here.

Traits§

SQLStatement
Any struct implementing this trait can be converted into an SQL statement String. Optionally, the statement can be wrapped in an SQL Transaction and/or guarded against already existing Tables with a ...IF NOT EXISTS... guard.

Type Aliases§

Result
Result type used in this crate, Error type is Error