sqldbmapper

A command line utility for generating rust mappings to databases.

Connects to a PostgreSQL database and creates a rust module representing all the schemas complete with mappings for stored functions/procedures

Defaults to creating an async wrapping using tokio-postgres but has a flag to make synchronous functions with postgres instead

Notes

Once generated the generated code does not contain additional checks that the database schema hasn't changed. While some type conversions will fail on the call care should be taken to update the generated code at the same time as the database

All functions generated take the client used to connect to the database as the first argument

SQL procedures/functons which are overloaded (two with the same name and different arguments) are mapped in this crate to functions which take a single tuple i,e, my_func((client, id, "hello")) and my_func((client, id)) this means overloading a previously not overloaded SQL procedure would be a breaking change with regards to the generated code

Help

``` sqldbmapper 0.0.2 Generate a rust wrapper for a PostgreSQL database

USAGE: sqldbmapper [FLAGS] [output]

FLAGS: -d, --debug Activate debug mode -h, --help Prints help information -s, --sync Generate synchronous mapping -u, --ugly Skip running output through rustfmt -V, --version Prints version information

ARGS: String to connect to database, see tokio_postgres::Config for details Output file, stdout if not present ```

sqldbmapper_core

Contains reexports and helper types which the generated code pulls in

sqldbmapper_derive

Features a derive macro from TryFromRow (defined in sqldbmapper_core) which provides conversions from postgres' Row struct

Future Work

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.