dml-tools
dml-tools is a library for DML generation and serialization from/to code or YAML files
See examples for usage.
Install
# Cargo.toml
[]
= "0.2"
Usage
To obtain this DML (Data Manipulation Language) definitions:
;
(
workspace text NULL,
user_id text NULL,
user_name text NULL,
full_name text NULL,
"role" text NULL,
is_locked text NULL,
email text NULL,
is_locked_by_supervisor text NULL,
CONSTRAINT my_table_my_reftable_field1_field2_fk FOREIGN KEY (field1,field2) REFERENCES schema1.my_reftable (rfield1, rfield2) ON DELETE RESTRICT ON UPDATE CASCADE
);
One can either, load it from this YAML file:
- tag: Schema
name: my_schema
owner: rw_user
- tag: Table
path:
schema: my_schema
name: users
otype: Table
fields:
- name: workspace
attributes:
unique: true
primary_key: true
- name: user_id
attributes:
empty: false
primary_key: true
- name: user_name
attributes:
unique: true
- name: full_name
attributes:
- name: role
attributes:
empty: false
- name: is_locked
attributes:
type: bool
empty: false
- name: email
attributes:
- name: is_locked_by_supervisor
attributes:
type: bool
empty: false
defval: 'false'
- tag: ForeignKey
table:
schema: schema1
name: my_table
otype: Table
fields:
- field1
- field2
ref_table:
schema: schema1
name: my_reftable
otype: Table
ref_fields:
- rfield1
- rfield2
on_delete: Restrict
on_update: Cascade
with this code:
use Loader;
use Processor;
use Error;
Or, generate it with this code:
use *;
use Processor;
use Error;
use *;
License
Licensed under MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)