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 DnsServerCore.ApplicationCommon;
using MySql.Data.MySqlClient; using MySqlConnector;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
@@ -634,10 +634,10 @@ CREATE TABLE IF NOT EXISTS dns_logs
command.Parameters.AddWithValue("@qname", qname); command.Parameters.AddWithValue("@qname", qname);
if (qtype is not null) if (qtype is not null)
command.Parameters.AddWithValue("@qtype", (ushort)qtype); command.Parameters.AddWithValue("@qtype", (short)qtype);
if (qclass is not null) if (qclass is not null)
command.Parameters.AddWithValue("@qclass", (ushort)qclass); command.Parameters.AddWithValue("@qclass", (short)qclass);
totalEntries = Convert.ToInt64(await command.ExecuteScalarAsync() ?? 0L); totalEntries = Convert.ToInt64(await command.ExecuteScalarAsync() ?? 0L);
} }
@@ -714,10 +714,10 @@ ORDER BY row_num" + (descendingOrder ? " DESC" : "");
command.Parameters.AddWithValue("@qname", qname); command.Parameters.AddWithValue("@qname", qname);
if (qtype is not null) if (qtype is not null)
command.Parameters.AddWithValue("@qtype", (ushort)qtype); command.Parameters.AddWithValue("@qtype", (short)qtype);
if (qclass is not null) if (qclass is not null)
command.Parameters.AddWithValue("@qclass", (ushort)qclass); command.Parameters.AddWithValue("@qclass", (short)qclass);
await using (DbDataReader reader = await command.ExecuteReaderAsync()) await using (DbDataReader reader = await command.ExecuteReaderAsync())
{ {