-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add docs in website for sqlite/mysql/postgresql services (#3290)
Signed-off-by: Manjusaka <[email protected]>
- Loading branch information
Showing
4 changed files
with
208 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |