Skip to content

kumanote/tidb-example-rs

Repository files navigation

tidb-example-rs

Outline

It's an example for Rust and TiDB. Contains subproject:

This is a process about the game, each player has two attributes, coins and goods, and each player has their own unique id as an identifier. Players can trade with each other, provided that the coins and goods are sufficient

The process is as follows:

  1. Create a player
  2. Create some players
  3. Read players amount
  4. Read some players attributes
  5. Two player trade with insufficient coins or goods
  6. Two player trade with sufficient coins or goods

Dependency

  • Rust with Cargo
    • There is no specific MSRV(Minimum Supported Rust Version)
    • Only tested with the latest stable version Rust compiler (older/nightly builds may work...)
  • diesel_cli

Diesel example

It's an example used diesel with mysql feature to connect TiDB.

Running way

  • Run diesel migration run to init schema in your tidb.
  • Run cargo build --release to build entrypoint to test.
  • Run ./target/release/tidb-example-cmd to start.

Expected output

diesel example expected output

Code

http example

It's an example service used diesel to connect TiDB. Provide a group of HTTP Restful interface.

Running way

  • Run diesel migration run to init schema in your tidb.
  • Run cargo build --release to build entrypoint to test.
  • Run ./target/release/tidb-example-server to start.
  • Using script to request. It's based on curl

Expected output

  1. request expected output

Code

License

This software includes the work that is distributed in the Apache License 2.0.

About

A set of examples of using Rust lang to connect to TiDB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors