Skip to content

Commit

Permalink
Merge pull request #4801 from BohuTANG/doc-deploy-python
Browse files Browse the repository at this point in the history
chore(doc): add create user for deploy
  • Loading branch information
BohuTANG authored Apr 12, 2022
2 parents 1f88817 + adfc32e commit 852dcf7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
20 changes: 17 additions & 3 deletions docs/doc/20-develop/01-python.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ description:

* **Databend :** Make sure Databend is running and accessible, see [How to deploy Databend](/doc/deploy).

### Create a user and grant privileges

```shell
mysql -h127.0.0.1 -uroot -P3307
```

```sql title='mysql>'
create user 'databend'@'%' IDENTIFIED BY 'password123';
```

```sql title='mysql>'
grant all privileges on *.* TO 'databend'@'%';
```

### Python

This guideline show how to connect and query to Databend using Python.
Expand All @@ -22,10 +36,10 @@ We will be creating a table named `books` and insert a row, then query it.
#!/usr/bin/env python3
import mysql.connector

cnx = mysql.connector.connect(user='root', password='',
cnx = mysql.connector.connect(user='databend', password='password123',
host='127.0.0.1',
port = 3307,
database='book_db')
database='')

# Create database, table.
cursor = cnx.cursor()
Expand Down Expand Up @@ -59,7 +73,7 @@ cnx.close()

import sqlalchemy

engine = sqlalchemy.create_engine("mysql+pymysql://root:root@localhost:3307/")
engine = sqlalchemy.create_engine("mysql+pymysql://databend:password123@localhost:3307/")
conn = engine.connect()
conn.execute("create database if not exists book_db")
conn.execute("use book_db")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,22 @@ show users;
+--------+-----------+----------------------+------------------------------------------------------------------+
| user-b | localhost | sha256_password | 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 |
+--------+-----------+----------------------+------------------------------------------------------------------+
```
```

### Grant privileges to the user

```text title='mysql>'
grant all privileges on *.* TO 'user-a'@'%';
```

```text
show grants for 'user-a'@'%';
```

```text
+------------------------------------------+
| Grants |
+------------------------------------------+
| GRANT ALL ON 'default'.* TO 'user-a'@'%' |
+------------------------------------------+
```

1 comment on commit 852dcf7

@vercel
Copy link

@vercel vercel bot commented on 852dcf7 Apr 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

databend – ./

databend-databend.vercel.app
databend-git-main-databend.vercel.app
databend.rs
databend.vercel.app

Please sign in to comment.