Skip to content

Commit

Permalink
create database if not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
maikebing committed Jan 7, 2023
1 parent ad210ea commit cd73095
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Example/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ private static void ExecSqlByWebSocket(TaosConnectionStringBuilder builder)
connection.Open();
Console.WriteLine("ServerVersion:{0}", connection.ServerVersion);
connection.DatabaseExists(database);
Console.WriteLine("create {0} {1}", database, connection.CreateCommand($"create database {database};").ExecuteNonQuery());
Console.WriteLine("create {0} {1}", database, connection.CreateCommand($"create database if not exists {database};").ExecuteNonQuery());
Console.WriteLine("create table t {0} {1}", database, connection.CreateCommand($"create table {database}.t (ts timestamp, cdata binary(255));").ExecuteNonQuery());
Console.WriteLine("insert into t values {0} ", connection.CreateCommand($"insert into {database}.t values ({(long)(DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalMilliseconds)}, 10);").ExecuteNonQuery());
Console.WriteLine("create {0} {1}", database, connection.CreateCommand($"use {database};").ExecuteNonQuery());
Expand Down Expand Up @@ -349,7 +349,7 @@ private static void ExecSqlByRESTFul(TaosConnectionStringBuilder builder_rest)
connection.Open();
Console.WriteLine("ServerVersion:{0}", connection.ServerVersion);
connection.DatabaseExists(database);
Console.WriteLine("create {0} {1}", database, connection.CreateCommand($"create database {database};").ExecuteNonQuery());
Console.WriteLine("create {0} {1}", database, connection.CreateCommand($"create database if not exists {database};").ExecuteNonQuery());
Console.WriteLine("create table t {0} {1}", database, connection.CreateCommand($"create table {database}.t (ts timestamp, cdata binary(255));").ExecuteNonQuery());
Console.WriteLine("insert into t values {0} ", connection.CreateCommand($"insert into {database}.t values ({(long)(DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalMilliseconds)}, 10);").ExecuteNonQuery());
Console.WriteLine("create {0} {1}", database, connection.CreateCommand($"use {database};").ExecuteNonQuery());
Expand Down

0 comments on commit cd73095

Please sign in to comment.