mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Update TDenine Test
This commit is contained in:
parent
9367fced21
commit
f5c6172ef2
@ -6,7 +6,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="TDengine.Ado.Data" Version="1.6.4" />
|
<PackageReference Include="TDengine.Ado.Data" Version="1.6.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using SqlSugar.TDengineAdo;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -54,7 +55,7 @@ namespace SqlSugar.TDengine
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "CREATE DATABASE {0}";
|
return "CREATE DATABASE IF NOT EXISTS {0} WAL_RETENTION_PERIOD 3600";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string AddPrimaryKeySql
|
protected override string AddPrimaryKeySql
|
||||||
@ -221,6 +222,13 @@ namespace SqlSugar.TDengine
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#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)
|
public override List<string> GetIndexList(string tableName)
|
||||||
{
|
{
|
||||||
var sql = $"SELECT indexname, indexdef FROM pg_indexes WHERE upper(tablename) = upper('{tableName}')";
|
var sql = $"SELECT indexname, indexdef FROM pg_indexes WHERE upper(tablename) = upper('{tableName}')";
|
||||||
@ -275,37 +283,6 @@ namespace SqlSugar.TDengine
|
|||||||
return result;
|
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)
|
public override bool AddRemark(EntityInfo entity)
|
||||||
{
|
{
|
||||||
var db = this.Context;
|
var db = this.Context;
|
||||||
|
@ -16,16 +16,16 @@ namespace OrmTest
|
|||||||
/// Account have permission to create database
|
/// Account have permission to create database
|
||||||
/// 用有建库权限的数据库账号
|
/// 用有建库权限的数据库账号
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// Account have permission to create database
|
/// Account have permission to create database
|
||||||
/// 用有建库权限的数据库账号
|
/// 用有建库权限的数据库账号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string ConnectionString2 = "Host=localhost;Port=6030;Username=root;Password=taosdata;Database=power";
|
public static string ConnectionString2 = ConnectionString;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Account have permission to create database
|
/// Account have permission to create database
|
||||||
/// 用有建库权限的数据库账号
|
/// 用有建库权限的数据库账号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string ConnectionString3 = "Host=localhost;Port=6030;Username=root;Password=taosdata;Database=power";
|
public static string ConnectionString3 = ConnectionString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)");
|
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");
|
||||||
|
|
||||||
|
|
||||||
//插入子表
|
//插入子表
|
||||||
|
Loading…
Reference in New Issue
Block a user