pub struct SQLExporter;Expand description
Exporter for SQL CREATE TABLE format.
Implementations§
Source§impl SQLExporter
impl SQLExporter
Sourcepub fn export_table(table: &Table, dialect: Option<&str>) -> String
pub fn export_table(table: &Table, dialect: Option<&str>) -> String
Export a table to SQL CREATE TABLE statement.
§Arguments
table- The table to exportdialect- Optional SQL dialect (“postgres”, “mysql”, “sqlserver”, etc.)
§Returns
A SQL CREATE TABLE statement as a string, with proper identifier quoting and escaping based on the dialect.
§Example
use data_modelling_core::export::sql::SQLExporter;
use data_modelling_core::models::{Table, Column};
let table = Table::new(
"users".to_string(),
vec![Column::new("id".to_string(), "INT".to_string())],
);
let sql = SQLExporter::export_table(&table, Some("postgres"));
// Returns: CREATE TABLE "users" (\n "id" INT\n);Sourcepub fn export(
&self,
tables: &[Table],
dialect: Option<&str>,
) -> Result<ExportResult, ExportError>
pub fn export( &self, tables: &[Table], dialect: Option<&str>, ) -> Result<ExportResult, ExportError>
Export tables to SQL CREATE TABLE statements (SDK interface).
§Arguments
tables- Slice of tables to exportdialect- Optional SQL dialect
§Returns
An ExportResult containing the SQL statements for all tables.
§Example
use data_modelling_core::export::sql::SQLExporter;
use data_modelling_core::models::{Table, Column};
let tables = vec![
Table::new("users".to_string(), vec![Column::new("id".to_string(), "INT".to_string())]),
Table::new("orders".to_string(), vec![Column::new("id".to_string(), "INT".to_string())]),
];
let exporter = SQLExporter;
let result = exporter.export(&tables, Some("postgres")).unwrap();
assert_eq!(result.format, "sql");Auto Trait Implementations§
impl Freeze for SQLExporter
impl RefUnwindSafe for SQLExporter
impl Send for SQLExporter
impl Sync for SQLExporter
impl Unpin for SQLExporter
impl UnwindSafe for SQLExporter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more