Method WriteDatabase
- Namespace
- YndigoBlue.Velocity.Engine
- Assembly
- YndigoBlue.Velocity.dll
WriteDatabase(Database, string, ConfigType, bool)
Writes a database definition (with multiple schemas) to a file in the specified format.
public void WriteDatabase(Database database, string path, ConfigType configType, bool ignoreUpdateAttributes = true)
Parameters
databaseDatabaseThe Database object to write to the file.
pathstringThe file path where the database definition will be written.
configTypeConfigTypeThe format to use (XML, JSON, or YAML).
ignoreUpdateAttributesboolIf true, excludes transient schema update metadata from the output.
Examples
using (var m = new Manager(conn))
{
// Load all schemas from database
var database = m.LoadDatabase();
// Write to JSON file
m.WriteDatabase(database, "database.json", ConfigType.Json);
Console.WriteLine($"Exported {database.Schemas.Count} schemas");
}
Remarks
WARNING: Multi-schema database operations are not available in the Community Edition of Velocity. They require the Full Edition.
Exceptions
- DbException
Thrown when a database error occurs.
WriteDatabase(Database, Stream, ConfigType, bool)
Writes a database definition (with multiple schemas) to a stream in the specified format.
public void WriteDatabase(Database database, Stream stream, ConfigType configType, bool ignoreUpdateAttributes = true)
Parameters
databaseDatabaseThe Database object to write to the stream.
streamStreamThe writable stream where the database definition will be written.
configTypeConfigTypeThe format to use (XML, JSON, or YAML).
ignoreUpdateAttributesboolIf true, excludes transient schema update metadata from the output.
Examples
using (var m = new Manager(conn))
using (var stream = new MemoryStream())
{
var database = m.LoadDatabase();
// Write to stream
m.WriteDatabase(database, stream, ConfigType.Yaml);
// Access the YAML
stream.Position = 0;
using (var reader = new StreamReader(stream))
{
string yaml = reader.ReadToEnd();
Console.WriteLine(yaml);
}
}
Remarks
WARNING: Multi-schema database operations are not available in the Community Edition of Velocity. They require the Full Edition.
Exceptions
- DbException
Thrown when a database error occurs.