-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a new sub command 'source' to print the database schema (#226)
- Loading branch information
Filip Kieres
authored
Oct 14, 2022
1 parent
8a918eb
commit 7714dd0
Showing
18 changed files
with
506 additions
and
48 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod dump; | ||
pub mod source; | ||
pub mod transformer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::io::{Error, ErrorKind}; | ||
|
||
use crate::config::{Config, ConnectionUri}; | ||
use crate::source::Explain; | ||
use crate::source::mongodb::MongoDB; | ||
use crate::source::mysql::Mysql; | ||
use crate::source::postgres::Postgres; | ||
|
||
/// show the database schema | ||
pub fn schema(config: Config) -> anyhow::Result<()> { | ||
match config.source { | ||
Some(source) => { | ||
match source.connection_uri()? { | ||
ConnectionUri::Postgres(host, port, username, password, database) => { | ||
let postgres = Postgres::new( | ||
host.as_str(), | ||
port, | ||
database.as_str(), | ||
username.as_str(), | ||
password.as_str(), | ||
); | ||
|
||
postgres.schema()?; | ||
|
||
Ok(()) | ||
} | ||
ConnectionUri::Mysql(host, port, username, password, database) => { | ||
let mysql = Mysql::new( | ||
host.as_str(), | ||
port, | ||
database.as_str(), | ||
username.as_str(), | ||
password.as_str(), | ||
); | ||
|
||
mysql.schema()?; | ||
|
||
Ok(()) | ||
} | ||
ConnectionUri::MongoDB(uri, database) => { | ||
let mongodb = MongoDB::new(uri.as_str(), database.as_str()); | ||
|
||
mongodb.schema()?; | ||
|
||
Ok(()) | ||
} | ||
} | ||
} | ||
None => { | ||
Err(anyhow::Error::from(Error::new( | ||
ErrorKind::Other, | ||
"missing <source> object in the configuration file", | ||
))) | ||
} | ||
} | ||
} |
Oops, something went wrong.