ClickHouse.Client
ClickHouse.Client copied to clipboard
Inserting data, how?
I'm stuck on the most trivial aspect of just inserting data and I don't find anything in the docs that helps me with this
The calling code:
var span = new Span
{
timestamp = DateTimeOffset.Now,
trace_id = "1234567890",
model = "test"
};
await InsertSpan(connection, span);
The entity:
[PublicAPI]
public class Span
{
public DateTimeOffset timestamp { get; set; }
public string trace_id { get; set; }
public string model { get; set; }
}
The code to insert an entity:
async Task InsertSpan(IDbConnection conn, Span span)
{
var sqlInsert =
"""
INSERT
INTO spans (timestamp, trace_id, model)
VALUES (@timestamp, @trace_id, @model)
""";
var res = await conn.ExecuteAsync(sqlInsert, span);
Console.WriteLine(res);
}
It throws with the following exception:
Unhandled exception. ClickHouse.Client.ClickHouseServerException (0x0000003E): Code: 62. DB::Exception: Cannot parse expression of type DateTime64(9) here: @timestamp, @trace_id, @model): While executing ValuesBlockInputFormat. (SYNTAX_ERROR) (version 23.2.1.2537 (official build))
Is it a me problem? is it a library problem? is it a Clickhouse issue?