Skip to content

Commit 71c8b74

Browse files
committed
Connect: Add Dart
1 parent c2721f4 commit 71c8b74

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

docs/_assets/icon/dart-logo.svg

Lines changed: 22 additions & 0 deletions
Loading

docs/connect/dart/index.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
(connect-dart)=
2+
3+
# Dart
4+
5+
:::{div} sd-text-muted
6+
Connect to CrateDB from Dart applications.
7+
:::
8+
9+
:::{rubric} About
10+
:::
11+
12+
[postgres] is a library for connecting to and querying PostgreSQL databases.
13+
14+
:::{rubric} Synopsis
15+
:::
16+
17+
`pubspec.yaml`
18+
```yaml
19+
name: cratedb_demo
20+
21+
dependencies:
22+
postgres: '^3.0.0'
23+
24+
environment:
25+
sdk: '^3.9.0'
26+
```
27+
28+
`example.dart`
29+
```dart
30+
library;
31+
32+
import 'package:postgres/postgres.dart';
33+
34+
void main() async {
35+
36+
final conn = await Connection.openFromUrl(
37+
'postgresql://crate:crate@localhost:5432/doc?sslmode=disable'
38+
);
39+
40+
final result = await conn.execute("SELECT mountain, region, height FROM sys.summits ORDER BY height DESC LIMIT 3");
41+
print(result);
42+
43+
await conn.close();
44+
}
45+
```
46+
47+
:::{include} ../_cratedb.md
48+
:::
49+
```shell
50+
dart --disable-analytics
51+
dart pub get
52+
dart example.dart
53+
```
54+
55+
:::{rubric} CrateDB Cloud
56+
:::
57+
58+
For connecting to CrateDB Cloud, use the `sslmode=require`
59+
parameter, and replace username, password, and hostname with values matching
60+
your environment.
61+
```dart
62+
final conn = await Connection.openFromUrl(
63+
'postgresql://admin:[email protected]:5432/doc?sslmode=require'
64+
);
65+
```
66+
67+
68+
[postgres]: https://pub.dev/packages/postgres

docs/connect/index.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ CrateDB drivers and adapters for supported programming languages, frameworks, an
4949
:margin: 4 4 0 0
5050
:padding: 0
5151

52+
::::{grid-item-card} Dart
53+
:link: connect-dart
54+
:link-type: ref
55+
:link-alt: Connect to CrateDB using Dart
56+
:padding: 3
57+
:text-align: center
58+
:class-card: sd-pt-3
59+
:class-body: sd-fs-1
60+
:class-title: sd-fs-6
61+
```{image} /_assets/icon/dart-logo.svg
62+
:height: 50px
63+
```
64+
::::
65+
5266
::::{grid-item-card} Java
5367
:link: connect-java
5468
:link-type: ref
@@ -182,6 +196,7 @@ application
182196
:maxdepth: 1
183197
:hidden:
184198
199+
dart/index
185200
java
186201
javascript
187202
php

0 commit comments

Comments
 (0)