/// <summary> /// Sets the Engine to use PostgreSql as its datastore. /// </summary> public EngineSetup UsePostgreSql(PostgresConfig config) { if (string.IsNullOrEmpty(config.Host)) { throw new ArgumentException("PostgreSql hostname must be provided in the config."); } if (string.IsNullOrEmpty(config.DatabaseName)) { throw new ArgumentException("PostgreSql database name must be provided in the config."); } _dbProviderFactory = logger => new PostgresDbProvider(config, logger); return(this); }
static void Main(string[] args) { IConfiguration config = LoadConfiguration(); PostgresConfig pgconf = config.GetSection("PostgreSQL").Get <PostgresConfig>(); SqlFolders sqlFolders = config.GetSection("SqlFolders").Get <SqlFolders>(); string pgConnectionString = BuildConnectionString(pgconf); List <string> scripts = GetOrderedScriptPaths(sqlFolders); foreach (string s in scripts) { ExecuteSqlScript(s, pgConnectionString); } }
public string Start(IRuntimeConfig runtimeConfig, int port, string dbName, string user, string password, IReadOnlyCollection <string> additionalParams) { var newConfig = new PostgresConfig(config.Distribution, port, dbName, config.DataDir, user, password, additionalParams); process = new PostgresProcess(newConfig, runtimeConfig); process.Start(); return(newConfig.ToConnectionString()); }
public static IServiceProvider Build() { var webRequestHeaders = new Dictionary <string, string> { { "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" } }; var webRequestConfig = new WebRequestConfig(1000, null, webRequestHeaders); var loggingConfig = new LoggingConfig( @"D:\Repos\ffdb_data_3\dev_test_logs\", maxBytes: null, RollingInterval.Day, rollOnFileSizeLimit: false, useDebugLogLevel: true, messageTemplate: @"{Timestamp:MM-dd HH:mm:ss} [{PipelineStage}] {Message:lj}{NewLine}{Exception}"); var postgresConfig = new PostgresConfig { DatabaseName = "ffdb_test_2", Host = "localhost", Username = "******", Password = "******" }; var programOptions = new ProgramOptions { SaveToDisk = true, SkipRosterFetch = true, SaveOriginalSourceFiles = true }; var baseServiceCollection = new EngineBaseServiceCollection(); ServiceCollection services = baseServiceCollection .SetRootDataPath(@"D:\Repos\ffdb_data_4\") .SetWebRequestConfig(webRequestConfig) .SetLoggingConfig(loggingConfig) .SetDatabaseProviderFactory(loggerFactory => new PostgresDbProvider(postgresConfig, loggerFactory)) .SetProgramOptions(programOptions) .Create(); return(services.BuildServiceProvider()); }
public Postgres(PostgresConfig postgresConfig) { this.postgresConfig = postgresConfig; ConnectionString = postgresConfig.ConnectionString(); connection = new NpgsqlConnection(ConnectionString); }
private static string BuildConnectionString(PostgresConfig pgConfig) { return($"User ID={pgConfig.User};Password={pgConfig.Password};Host={pgConfig.Hostname};Port={pgConfig.Port};Database={pgConfig.Database};SSL Mode=Require;Trust Server Certificate=true;"); }