Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions docs/_assets/icon/dart-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions docs/connect/dart/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
(connect-dart)=

# Dart

:::{div} sd-text-muted
Connect to CrateDB from Dart applications.
:::

:::{rubric} About
:::

[postgres] is a library for connecting to and querying PostgreSQL databases.

:::{rubric} Synopsis
:::

`pubspec.yaml`
```yaml
name: cratedb_demo

dependencies:
postgres: '^3.0.0'

environment:
sdk: '^3.9.0'
```

`example.dart`
```dart
library;

import 'package:postgres/postgres.dart';

void main() async {

final conn = await Connection.openFromUrl(
'postgresql://crate:crate@localhost:5432/?sslmode=disable'
);

final result = await conn.execute("SELECT mountain, region, height FROM sys.summits ORDER BY height DESC LIMIT 3");
print(result);

await conn.close();
}
```

:::{include} ../_cratedb.md
:::
```shell
dart --disable-analytics
dart pub get
dart example.dart
```

:::{rubric} SSL connection
:::

Use the `sslmode=require` parameter, and replace username, password,
and hostname with values matching your environment.
Also use this variant to connect to CrateDB Cloud.

```dart
final conn = await Connection.openFromUrl(
'postgresql://admin:password@testcluster.cratedb.net:5432/?sslmode=require'
);
```


[postgres]: https://pub.dev/packages/postgres
14 changes: 14 additions & 0 deletions docs/connect/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ Any (ODBC)
C#
::::

::::{grid-item-card}
:link: connect-dart
:link-type: ref
:link-alt: Connect to CrateDB using Dart
:class-body: sd-fs-1 sd-text-center
:class-footer: sd-fs-5 sd-font-weight-bold
```{image} /_assets/icon/dart-logo.svg
:height: 50px
```
+++
Dart
::::

::::{grid-item-card}
:link: connect-elixir
:link-type: ref
Expand Down Expand Up @@ -337,6 +350,7 @@ application
:hidden:

csharp/index
dart/index
elixir/index
erlang/index
fsharp/index
Expand Down