1
1
.. highlight: console
2
2
3
- =================================================================
4
- Basic demonstration program for using CrateDB with vanilla Npgsql
5
- =================================================================
3
+ #######################################################
4
+ Basic example for connecting to CrateDB using .NET (C#)
5
+ #######################################################
6
+
7
+
8
+ *****
9
+ About
10
+ *****
6
11
7
12
CrateDB versions prior to 4.2 needed a custom fork of the official Npgsql .NET
8
13
data provider for PostgreSQL, `crate-npgsql `_. CrateDB versions 4.2 and later
@@ -12,44 +17,45 @@ The file ``DemoProgram.cs`` is a demonstration program written in C# which
12
17
outlines typical, very basic usage scenarios with CrateDB.
13
18
14
19
20
+
21
+ *****
15
22
Usage
16
- =====
23
+ *****
17
24
18
25
To invoke a CrateDB instance for evaluation purposes, run::
19
26
20
- sh$ docker run -it --rm --publish=4200:4200 --publish=5432:5432 crate:4.5.1
27
+ docker run -it --rm --publish=4200:4200 --publish=5432:5432 crate:4.5.1
21
28
22
- For building and running the demonstration program and connect to
23
- ``localhost:5432 ``, invoke::
29
+ Invoke example program::
24
30
25
- sh$ dotnet run --framework=net5.0
31
+ dotnet run --framework=net5.0
26
32
27
33
To connect to CrateDB Cloud, use a command like::
28
34
29
- sh$ dotnet run --framework=net5.0 -- \
35
+ dotnet run --framework=net5.0 -- \
30
36
--host=clustername.aks1.westeurope.azure.cratedb.net --ssl-mode=Require \
31
37
--username=foobar --password='X8F%Shn)TESTvF5ac7%eW4NM'
32
38
33
39
Explore all available options::
34
40
35
- sh$ dotnet run --framework=net5.0 -- --help
41
+ dotnet run --framework=net5.0 -- --help
36
42
37
43
38
44
Tests
39
45
=====
40
46
41
47
For running the test scenarios wrapped into a xUnit test suite, invoke::
42
48
43
- sh$ dotnet test --framework=net5.0
49
+ dotnet test --framework=net5.0
44
50
45
51
To generate a Cobertura code coverage report, run::
46
52
47
- sh$ dotnet test --framework=net5.0 --collect:"XPlat Code Coverage"
53
+ dotnet test --framework=net5.0 --collect:"XPlat Code Coverage"
48
54
49
55
For running the tests against a remote database, use, for example::
50
56
51
- sh$ export CRATEDB_DSN='Host=clustername.aks1.westeurope.azure.cratedb.net;Port=5432;SSL Mode=Require;Username=foobar;Password=X8F%Shn)TESTvF5ac7%eW4NM;Database=testdrive'
52
- sh$ dotnet test --framework=net5.0
57
+ export CRATEDB_DSN='Host=clustername.aks1.westeurope.azure.cratedb.net;Port=5432;SSL Mode=Require;Username=foobar;Password=X8F%Shn)TESTvF5ac7%eW4NM;Database=testdrive'
58
+ dotnet test --framework=net5.0
53
59
54
60
55
61
.. _crate-npgsql : https://github.com/crate/crate-npgsql
0 commit comments