feat(core): add database utils
This commit is contained in:
parent
bc3421b150
commit
d8ed9fd25a
3 changed files with 13 additions and 9 deletions
|
@ -4,6 +4,5 @@ version = "0.1.0"
|
||||||
authors = ["Dmitriy Pleshevskiy <dmitriy@ideascup.me>"]
|
authors = ["Dmitriy Pleshevskiy <dmitriy@ideascup.me>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
postgres = "0.19.0"
|
||||||
|
|
9
migra-core/src/database.rs
Normal file
9
migra-core/src/database.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
use postgres::{Client, NoTls, Error};
|
||||||
|
|
||||||
|
pub fn connect(connection_string: &str) -> Result<Client, Error> {
|
||||||
|
Client::connect(connection_string, NoTls)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn apply_sql(client: &mut Client, sql_content: &str) -> Result<(), Error> {
|
||||||
|
client.batch_execute(sql_content)
|
||||||
|
}
|
|
@ -1,7 +1,3 @@
|
||||||
#[cfg(test)]
|
#![deny(clippy::all)]
|
||||||
mod tests {
|
|
||||||
#[test]
|
pub mod database;
|
||||||
fn it_works() {
|
|
||||||
assert_eq!(2 + 2, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Reference in a new issue