Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add docs in website for sqlite/mysql/postgresql services #3290

Merged
merged 1 commit into from
Oct 16, 2023
Merged
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
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>