private static int DoInitRun() { if (String.IsNullOrEmpty(dbSchema)) { if (dbType == "core") { dbSchema = CORE_DEFAULT_SCHEMA_NAME; } else if (dbType == "rdb") { dbSchema = RDB_DEFAULT_SCHEMA_NAME; } } if (!VerifyDatabaseParameters()) { PrintUsage(); return 1; } MySqlConnection conn = new MySqlConnection( String.Format("Data Source={0};User ID={1};password={2}", dbHost, dbUser, dbPass)); try { conn.Open(); } catch (MySqlException e) { Console.Error.WriteLine("Unable to connect to the database: {0}", e.Message); return 1; } //create the schema if it is missing try { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = String.Format("CREATE DATABASE IF NOT EXISTS {0};", dbSchema); cmd.ExecuteNonQuery(); } catch (MySqlException e) { Console.Error.WriteLine("Unable to create database schema: {0}", e.Message); return 1; } //for the core database, we'll actually open up and run both the //core file and the RDB file. that way, a user can run both from //the same database if (dbType == "core") { try { SqlFileRunner coreRunner = new SqlFileRunner(conn, dbSchema, CORE_SCHEMA_BASE_FILE); coreRunner.Run(); } catch (Exception e) { Console.Error.WriteLine("Unable to load CORE schema: {0}", e.Message); return 1; } } if (dbType == "core" || dbType == "rdb") { try { SqlFileRunner rdbRunner = new SqlFileRunner(conn, dbSchema, RDB_SCHEMA_BASE_FILE); rdbRunner.Run(); } catch (Exception e) { Console.Error.WriteLine("Unable to load RDB schema: {0}", e.Message); return 1; } } return 0; }
private static int DoInitRun() { if (String.IsNullOrEmpty(_dbSchema)) { if ((_dbType == "core") || (_dbType == "both")) { _dbSchema = CoreDefaultSchemaName; } else if (_dbType == "rdb") { _dbSchema = RdbDefaultSchemaName; } } if (!VerifyDatabaseParameters()) { PrintUsage(); return(1); } MySqlConnection conn = new MySqlConnection( String.Format("Data Source={0};User ID={1};password={2}", _dbHost, _dbUser, _dbPass)); try { conn.Open(); } catch (MySqlException e) { Console.Error.WriteLine("Unable to connect to the database: {0}", e.Message); return(1); } //create the schema if it is missing try { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = String.Format("CREATE DATABASE IF NOT EXISTS {0};", _dbSchema); cmd.ExecuteNonQuery(); } catch (MySqlException e) { Console.Error.WriteLine("Unable to create database schema: {0}", e.Message); return(1); } if ((_dbType == "core") || (_dbType == "both")) { try { SqlFileRunner coreRunner = new SqlFileRunner(conn, _dbSchema, CoreSchemaBaseFile); coreRunner.Run(); } catch (Exception e) { Console.Error.WriteLine("Unable to load CORE schema: {0}", e.Message); return(1); } } if (_dbType == "rdb" || _dbType == "both") { try { SqlFileRunner rdbRunner = new SqlFileRunner(conn, _dbSchema, RdbSchemaBaseFile); rdbRunner.Run(); } catch (Exception e) { Console.Error.WriteLine("Unable to load RDB schema: {0}", e.Message); return(1); } } return(0); }
private static int DoInitRun() { if (String.IsNullOrEmpty(dbSchema)) { if (dbType == "core") { dbSchema = CORE_DEFAULT_SCHEMA_NAME; } else if (dbType == "rdb") { dbSchema = RDB_DEFAULT_SCHEMA_NAME; } } if (!VerifyDatabaseParameters()) { PrintUsage(); return(1); } MySqlConnection conn = new MySqlConnection( String.Format("Data Source={0};User ID={1};password={2}", dbHost, dbUser, dbPass)); try { conn.Open(); } catch (MySqlException e) { Console.Error.WriteLine("Unable to connect to the database: {0}", e.Message); return(1); } //create the schema if it is missing try { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = String.Format("CREATE DATABASE IF NOT EXISTS {0};", dbSchema); cmd.ExecuteNonQuery(); } catch (MySqlException e) { Console.Error.WriteLine("Unable to create database schema: {0}", e.Message); return(1); } //for the core database, we'll actually open up and run both the //core file and the RDB file. that way, a user can run both from //the same database if (dbType == "core") { try { SqlFileRunner coreRunner = new SqlFileRunner(conn, dbSchema, CORE_SCHEMA_BASE_FILE); coreRunner.Run(); } catch (Exception e) { Console.Error.WriteLine("Unable to load CORE schema: {0}", e.Message); return(1); } } if (dbType == "core" || dbType == "rdb") { try { SqlFileRunner rdbRunner = new SqlFileRunner(conn, dbSchema, RDB_SCHEMA_BASE_FILE); rdbRunner.Run(); } catch (Exception e) { Console.Error.WriteLine("Unable to load RDB schema: {0}", e.Message); return(1); } } return(0); }