FarmMapsApiClient_WURtest/FarmmapsBulkSatDownload/Models/DB.cs
pepijn van oort 1bc326cfd2 Projects FarmmapsBulkSatDownload and FarmmapsDataDownload fully updated and tested
Added some extra Tasks to /FarmmapsApi/Services/GeneralService.cs
Added class SatelliteStatistics.cs to /FarmmapsApi/Models
2021-05-26 10:16:29 +02:00

48 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using Npgsql;
namespace FarmmapsBulkSatDownload.Models
{
public class DB
{
public string Database;
public string User;
public string Password;
public string Host;
public string GetConnectionString()
{
NpgsqlConnectionStringBuilder sb = new NpgsqlConnectionStringBuilder();
sb.Database = Database;
sb.Host = Host;
sb.Username = User;
sb.Password = Password;
sb.Port = 5432;
return sb.ConnectionString;
}
public int ExecuteNonQuery(string sql)
{
using (NpgsqlConnection conn = new NpgsqlConnection(GetConnectionString()))
{
conn.Open();
NpgsqlCommand command = conn.CreateCommand();
command.CommandText = sql;
int r = command.ExecuteNonQuery();
return r;
}
}
public NpgsqlConnection CreateConnection()
{
NpgsqlConnection conn = new NpgsqlConnection(GetConnectionString());
conn.Open();
return conn;
}
}
}