QueryLogsMySql: changed driver to MySqlConnector which supports mariadb too. Fixed minor issues.

This commit is contained in:
Shreyas Zare
2025-02-15 12:34:03 +05:30
parent 521caade7b
commit b5d4c80164

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using DnsServerCore.ApplicationCommon;
using MySql.Data.MySqlClient;
using MySqlConnector;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -370,7 +370,7 @@ CREATE TABLE IF NOT EXISTS dns_logs
catch
{ }
}
await using (MySqlCommand command = connection.CreateCommand())
{
command.CommandText = "CREATE INDEX index_timestamp ON dns_logs (timestamp);";
@@ -634,10 +634,10 @@ CREATE TABLE IF NOT EXISTS dns_logs
command.Parameters.AddWithValue("@qname", qname);
if (qtype is not null)
command.Parameters.AddWithValue("@qtype", (ushort)qtype);
command.Parameters.AddWithValue("@qtype", (short)qtype);
if (qclass is not null)
command.Parameters.AddWithValue("@qclass", (ushort)qclass);
command.Parameters.AddWithValue("@qclass", (short)qclass);
totalEntries = Convert.ToInt64(await command.ExecuteScalarAsync() ?? 0L);
}
@@ -714,10 +714,10 @@ ORDER BY row_num" + (descendingOrder ? " DESC" : "");
command.Parameters.AddWithValue("@qname", qname);
if (qtype is not null)
command.Parameters.AddWithValue("@qtype", (ushort)qtype);
command.Parameters.AddWithValue("@qtype", (short)qtype);
if (qclass is not null)
command.Parameters.AddWithValue("@qclass", (ushort)qclass);
command.Parameters.AddWithValue("@qclass", (short)qclass);
await using (DbDataReader reader = await command.ExecuteReaderAsync())
{