Skip to content

Commit

Permalink
Update dev-guide-sample-application-python-sqlalchemy.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreoxmt authored Sep 4, 2023
1 parent 16fedb2 commit 73534bb
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions develop/dev-guide-sample-application-python-sqlalchemy.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,49 +243,7 @@ class Player(Base):
For more information, refer to [SQLAlchemy documentation: Mapping classes with declarative](https://docs.sqlalchemy.org/en/20/orm/declarative_mapping.html).
<<<<<<< HEAD
The `Player` class is a mapping of a table to attributes in the application. Each attribute of `Player` corresponds to a field in the `player` table. To provide SQLAlchemy with more information, the attribute is defined as `id = Column(String(36), primary_key=True)` to indicate the field type and its additional attributes. For example, `id = Column(String(36), primary_key=True)` indicates that the `id` attribute is `String` type, the corresponding field in database is `VARCHAR` type, the length is `36`, and it is a primary key.
For more information about how to use SQLAlchemy, refer to [SQLAlchemy documentation](https://www.sqlalchemy.org/).
## Step 3. Run the code
The following content introduces how to run the code step by step.
### Step 3.1 Initialize table
Before running the code, you need to initialize the table manually. If you are using a local TiDB cluster, you can run the following command:
<SimpleTab groupId="cli">
<div label="MySQL CLI" value="mysql-client">
```shell
mysql --host 127.0.0.1 --port 4000 -u root < player_init.sql
```
</div>
<div label="MyCLI" value="mycli">
```shell
mycli --host 127.0.0.1 --port 4000 -u root --no-warn < player_init.sql
```
</div>
</SimpleTab>
If you are not using a local cluster, or have not installed a MySQL client, connect to your cluster using your preferred method (such as Navicat, DBeaver, or other GUI tools) and run the SQL statements in the `player_init.sql` file.
### Step 3.2 Modify parameters for TiDB Cloud
If you are using a TiDB Serverless cluster, you need to provide your CA root path and replace `<ca_path>` in the following examples with your CA path. To get the CA root path on your system, refer to [Root certificate management](https://docs.pingcap.com/tidbcloud/secure-connections-to-serverless-clusters#root-certificate-management).
If you are using a TiDB Serverless cluster, modify the parameters of the `create_engine` function in `sqlalchemy_example.py`:
=======
### Insert data
>>>>>>> 08af194ac6 (develop: refactor SQLAlchemy dev guide (#14638))
```python
with Session() as session:
Expand Down

0 comments on commit 73534bb

Please sign in to comment.