예제 #1
0
 public ClickHouseDB(TSchema schema, ClickHouseConnectionSettings settings, CreateDatabaseParameters createParams = null)
 {
     ProxyLog.Info($"{GetType().Name}: Database={settings.Database}; Server={settings.Host}:{settings.Port}");
     ConnectionSettings = settings;
     if (createParams == null)
     {
         CreateParameters = new CreateDatabaseParameters(ClickHouseNodeMode.Autonom);
     }
     else
     {
         CreateParameters = createParams;
         if (CreateParameters.NodeMode != ClickHouseNodeMode.Autonom)
         {
             if (string.IsNullOrWhiteSpace(CreateParameters.Cluster))
             {
                 CreateParameters.Cluster = ConnectionSettings.GetClusterName();
             }
             if (string.IsNullOrWhiteSpace(CreateParameters.Cluster))
             {
                 throw new ArgumentNullException(nameof(CreateParameters.Cluster));
             }
         }
         if (CreateParameters.NodeMode == ClickHouseNodeMode.Distributed)
         {
             if (string.IsNullOrWhiteSpace(CreateParameters.DistribitedSourceDatabaseName))
             {
                 CreateParameters.DistribitedSourceDatabaseName = ConnectionSettings.Database;
             }
         }
     }
     Schema       = schema;
     CommandText  = new DatabaseCommandText(schema);
     TableEngines = new Dictionary <Type, ITableEngine>();
     DefineTableEngines();
 }
예제 #2
0
 public ClickHouseDB(TSchema schema, string сonnectionString, CreateDatabaseParameters createParams = null)
     : this(schema, new ClickHouseConnectionSettings(сonnectionString), createParams)
 {
 }