Update TDenine Test

This commit is contained in:
sunkaixuan 2023-08-03 12:50:08 +08:00
parent 9367fced21
commit f5c6172ef2
4 changed files with 17 additions and 40 deletions

View File

@ -6,7 +6,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TDengine.Ado.Data" Version="1.6.4" />
<PackageReference Include="TDengine.Ado.Data" Version="1.6.6" />
</ItemGroup>
<ItemGroup>

View File

@ -1,4 +1,5 @@
using System;
using SqlSugar.TDengineAdo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -54,7 +55,7 @@ namespace SqlSugar.TDengine
{
get
{
return "CREATE DATABASE {0}";
return "CREATE DATABASE IF NOT EXISTS {0} WAL_RETENTION_PERIOD 3600";
}
}
protected override string AddPrimaryKeySql
@ -221,6 +222,13 @@ namespace SqlSugar.TDengine
#endregion
#region Methods
public override bool CreateDatabase(string databaseName,string databaseDirectory = null)
{
var db=this.Context.CopyNew();
db.Ado.Connection.ChangeDatabase("");
db.Ado.ExecuteCommand(string.Format(CreateDataBaseSql,databaseName));
return true;
}
public override List<string> GetIndexList(string tableName)
{
var sql = $"SELECT indexname, indexdef FROM pg_indexes WHERE upper(tablename) = upper('{tableName}')";
@ -275,37 +283,6 @@ namespace SqlSugar.TDengine
return result;
}
/// <summary>
///by current connection string
/// </summary>
/// <param name="databaseDirectory"></param>
/// <returns></returns>
public override bool CreateDatabase(string databaseName, string databaseDirectory = null)
{
if (databaseDirectory != null)
{
if (!FileHelper.IsExistDirectory(databaseDirectory))
{
FileHelper.CreateDirectory(databaseDirectory);
}
}
// var oldDatabaseName = this.Context.Ado.Connection.Database;
//var connection = this.Context.CurrentConnectionConfig.ConnectionString;
//connection = connection.Replace(oldDatabaseName, "");
if (this.Context.Ado.IsValidConnection())
{
return true;
}
var newDb = this.Context.CopyNew();
newDb.Ado.Connection.ChangeDatabase("highgo");
newDb.Open();
if (!GetDataBaseList(newDb).Any(it => it.Equals(databaseName, StringComparison.CurrentCultureIgnoreCase)))
{
newDb.Ado.ExecuteCommand(string.Format(CreateDataBaseSql, this.SqlBuilder.SqlTranslationLeft+databaseName+this.SqlBuilder.SqlTranslationRight, databaseDirectory));
}
newDb.Close();
return true;
}
public override bool AddRemark(EntityInfo entity)
{
var db = this.Context;

View File

@ -16,16 +16,16 @@ namespace OrmTest
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
public static string ConnectionString = "Host=localhost;Port=6030;Username=root;Password=taosdata;Database=power";
public static string ConnectionString = "Host=localhost;Port=6030;Username=root;Password=taosdata;Database=test";
/// <summary>
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
public static string ConnectionString2 = "Host=localhost;Port=6030;Username=root;Password=taosdata;Database=power";
public static string ConnectionString2 = ConnectionString;
/// <summary>
/// Account have permission to create database
/// 用有建库权限的数据库账号
/// </summary>
public static string ConnectionString3 = "Host=localhost;Port=6030;Username=root;Password=taosdata;Database=power";
public static string ConnectionString3 = ConnectionString;
}
}

View File

@ -29,9 +29,9 @@ namespace OrmTest
}
}
});
//建库
db.Ado.ExecuteCommand("CREATE DATABASE IF NOT EXISTS power WAL_RETENTION_PERIOD 3600");
db.DbMaintenance.CreateDatabase();
//建超级表
db.Ado.ExecuteCommand("CREATE STABLE IF NOT EXISTS St01 (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT, isdelete BOOL, name BINARY(64)) TAGS (location BINARY(64), groupId INT)");
@ -41,7 +41,7 @@ namespace OrmTest
//查询子表
var dt = db.Ado.GetDataTable("select * from MyTable02");
var dt = db.Ado.GetDataTable("SHOW DATABASES");
//插入子表