# Exercise 1: Database Connectors: PyMySQL

## Prerequisites
+ Your TiDB serverless cluster is up and running.
+ The Python environment is already configured on the operating system.
+ [git](https://git-scm.com/) is already installed on the operating system.

## Section 1: Preparation
1. Clone example scripts repository to the practice node (e.g: Your local macOS, Linux or VM in the Cloud).
```
$ git clone https://github.com/pingcap/tidb-course-201-lab
```

2. Go to working directory: `tidb-course-201-lab/scripts`.
```
$ cd tidb-course-201-lab/scripts
```

## Section 2: Making connection to TiDB Serverless
1. Go through the sample code - [DemoPythonConnectionServerless.py](https://github.com/pingcap/tidb-course-201-lab/blob/master/scripts/DemoPythonConnectionServerless.py).
  
    Pay attention line 6 to 16, where the connection is established.

2. Run demo script, and note the output.
```
$ ./09-demo-python-connection-serverless-01-show.sh <host> <user_name> <password>
```
    E.g. ./09-demo-python-connection-serverless-01-show.sh gateway01.ap-southeast-1.prod.aws.tidbcloud.com 3hB7dXAzsdPa5sc.root XRJCiu12FKsdzDpb