Now using single string for DB conns
This commit is contained in:
parent
ae782025f6
commit
6f326320cc
@ -22,13 +22,15 @@ namespace YTManager {
|
|||||||
|
|
||||||
public IConfiguration Configuration { get; }
|
public IConfiguration Configuration { get; }
|
||||||
|
|
||||||
|
// String used for connecting to the database server.
|
||||||
|
public static string dbstr { get; } = "Host=192.168.1.130;Database=postgres;Username=postgres;Password=pass";
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
string constr = "Host=home.hak8or.com;Database=postgres;Username=postgres;Password=mysecretpassword";
|
services.AddHangfire(x => x.UsePostgreSqlStorage(dbstr));
|
||||||
services.AddHangfire(x => x.UsePostgreSqlStorage(constr));
|
services.AddDbContext<MediaDB>(options => options.UseNpgsql(dbstr));
|
||||||
services.AddDbContext<MediaDB>(options => options.UseNpgsql(constr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
@ -22,8 +22,7 @@ namespace YTManager.Tasks
|
|||||||
|
|
||||||
// Get all the channels to update.
|
// Get all the channels to update.
|
||||||
var ops = new DbContextOptionsBuilder<MediaDB>();
|
var ops = new DbContextOptionsBuilder<MediaDB>();
|
||||||
string constr = "Host=home.hak8or.com;Database=postgres;Username=postgres;Password=mysecretpassword";
|
ops.UseNpgsql(YTManager.Startup.dbstr);
|
||||||
ops.UseNpgsql(constr);
|
|
||||||
using (var dbcontext = new MediaDB(ops.Options)) {
|
using (var dbcontext = new MediaDB(ops.Options)) {
|
||||||
var channels = dbcontext.Channels.ToList();
|
var channels = dbcontext.Channels.ToList();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user