Skip to content

Commit

Permalink
docs: Add docs in website for sqlite/mysql/postgresql services (#3290)
Browse files Browse the repository at this point in the history
Signed-off-by: Manjusaka <[email protected]>
  • Loading branch information
Zheaoli authored Oct 16, 2023
1 parent 945ff82 commit 14a62e0
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/services/sqlite/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This service can be used to:
## Configuration

- `root`: Set the working directory of `OpenDAL`
- `connection_string`: Set the connection string of postgres server
- `connection_string`: Set the connection string of sqlite database
- `table`: Set the table of sqlite
- `key_field`: Set the key field of sqlite
- `value_field`: Set the value field of sqlite
Expand Down
69 changes: 69 additions & 0 deletions website/docs/services/mysql.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: MySQL
---

[MySQL](https://www.mysql.com/) services support.

import Docs from '../../../core/src/services/mysql/docs.md'

<Docs components={props.components} />

### Via Config

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs>
<TabItem value="rust" label="Rust" default>

```rust
use anyhow::Result;
use opendal::services::Mysql;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {

let mut map = HashMap::new();
map.insert("connection_string".to_string(), "mysql://you_username:[email protected]:5432/your_database".to_string());
map.insert("table".to_string(), "your_table".to_string());
map.insert("key_field".to_string(), "your_key_field".to_string());
map.insert("value_field".to_string(), "your_value_field".to_string());

let op: Operator = Operator::via_map(Scheme::Mysql, map)?;
Ok(())
}
```

</TabItem>
<TabItem value="node.js" label="Node.js">

```javascript
import { Operator } from require('opendal');

async function main() {
const op = new Operator("mysql", {
connection_string: 'mysql://you_username:[email protected]:5432/your_database',
table: 'your_table',
key_field: 'your_key_field',
value_field: 'your_value_field',
});
}
```

</TabItem>
<TabItem value="python" label="Python">

```python
import opendal

op = opendal.Operator("mysql", {
"connection_string": "mysql://you_username:[email protected]:5432/your_database",
"table": "your_table",
"key_field": "your_key_field",
"value_field": "your_value_field",
})
```

</TabItem>
</Tabs>
69 changes: 69 additions & 0 deletions website/docs/services/postgresql.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: PostgreSQL
---

[PostgreSQL](https://www.postgresql.org/) services support.

import Docs from '../../../core/src/services/postgresql/docs.md'

<Docs components={props.components} />

### Via Config

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs>
<TabItem value="rust" label="Rust" default>

```rust
use anyhow::Result;
use opendal::services::Postgresql;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {

let mut map = HashMap::new();
map.insert("connection_string".to_string(), "postgresql://you_username:[email protected]:5432/your_database".to_string());
map.insert("table".to_string(), "your_table".to_string());
map.insert("key_field".to_string(), "your_key_field".to_string());
map.insert("value_field".to_string(), "your_value_field".to_string());

let op: Operator = Operator::via_map(Scheme::Postgresql, map)?;
Ok(())
}
```

</TabItem>
<TabItem value="node.js" label="Node.js">

```javascript
import { Operator } from require('opendal');

async function main() {
const op = new Operator("postgresql", {
connection_string: 'postgresql://you_username:[email protected]:5432/your_database',
table: 'your_table',
key_field: 'your_key_field',
value_field: 'your_value_field',
});
}
```

</TabItem>
<TabItem value="python" label="Python">

```python
import opendal

op = opendal.Operator("postgresql", {
"connection_string": "postgresql://you_username:[email protected]:5432/your_database",
"table": "your_table",
"key_field": "your_key_field",
"value_field": "your_value_field",
})
```

</TabItem>
</Tabs>
69 changes: 69 additions & 0 deletions website/docs/services/sqlite.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: Sqlite
---

[Sqlite](https://www.sqlite.org/) services support.

import Docs from '../../../core/src/services/sqlite/docs.md'

<Docs components={props.components} />

### Via Config

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs>
<TabItem value="rust" label="Rust" default>

```rust
use anyhow::Result;
use opendal::services::Sqlite;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {

let mut map = HashMap::new();
map.insert("connection_string".to_string(), "file//abc.db".to_string());
map.insert("table".to_string(), "your_table".to_string());
map.insert("key_field".to_string(), "your_key_field".to_string());
map.insert("value_field".to_string(), "your_value_field".to_string());

let op: Operator = Operator::via_map(Scheme::Sqlite, map)?;
Ok(())
}
```

</TabItem>
<TabItem value="node.js" label="Node.js">

```javascript
import { Operator } from require('opendal');

async function main() {
const op = new Operator("sqlite", {
connection_string: 'file//abc.db',
table: 'your_table',
key_field: 'your_key_field',
value_field: 'your_value_field',
});
}
```

</TabItem>
<TabItem value="python" label="Python">

```python
import opendal

op = opendal.Operator("sqlite", {
"connection_string": "file//abc.db",
"table": "your_table",
"key_field": "your_key_field",
"value_field": "your_value_field",
})
```

</TabItem>
</Tabs>

0 comments on commit 14a62e0

Please sign in to comment.