{"id":21042684,"url":"https://github.com/yugabytedb-samples/yugabyte-simple-rust-app","last_synced_at":"2025-07-07T04:07:27.458Z","repository":{"id":69256375,"uuid":"459652143","full_name":"YugabyteDB-Samples/yugabyte-simple-rust-app","owner":"YugabyteDB-Samples","description":"A simple Rust application that connects to a YugabyteDB database cluster and performs basic CRUD operations.","archived":false,"fork":false,"pushed_at":"2024-07-16T16:34:15.000Z","size":197,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":61,"default_branch":"main","last_synced_at":"2025-02-28T14:06:31.186Z","etag":null,"topics":["demos","rust","yugabytedb"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/YugabyteDB-Samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-15T16:08:32.000Z","updated_at":"2024-07-16T16:34:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"ab6de7aa-2efc-421a-9377-52b5f248d4e0","html_url":"https://github.com/YugabyteDB-Samples/yugabyte-simple-rust-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-rust-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-rust-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-rust-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabyte-simple-rust-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YugabyteDB-Samples","download_url":"https://codeload.github.com/YugabyteDB-Samples/yugabyte-simple-rust-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243489780,"owners_count":20298997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["demos","rust","yugabytedb"],"created_at":"2024-11-19T14:08:40.699Z","updated_at":"2025-03-13T21:43:06.376Z","avatar_url":"https://github.com/YugabyteDB-Samples.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Rust Application for YugabyteDB\n\nThis application connects to your YugabyteDB instance via the \n[Rust](https://github.com/sfackler/rust-postgres) driver for PostgreSQL and performs basic SQL operations. The instructions below are provided for [YugabyteDB Aeon](https://cloud.yugabyte.com/) deployments. \nIf you use a different type of deployment, then update the `src/sample-app.rs` file with proper connection parameters.\n\n## Prerequisite\n\n* [Rust](https://www.rust-lang.org/tools/install) development environment. The sample application was created for Rust 1.58 but should work for earlier and later versions.\n* Command line tool or your favorite IDE, such as Visual Studio Code.\n\n## Start YugabyteDB Aeon Cluster\n\n* [Start YugabyteDB Aeon](https://docs.yugabyte.com/latest/yugabyte-cloud/cloud-quickstart/qs-add/) instance. You can use\nthe free tier at no cost.\n* Add an IP address of your machine/laptop to the [IP allow list](https://docs.yugabyte.com/latest/yugabyte-cloud/cloud-secure-clusters/add-connections/#manage-ip-allow-lists)\n\n## Clone Application Repository\n\nClone the repository and change dirs into it:\n\n```bash\ngit clone https://github.com/YugabyteDB-Samples/yugabyte-simple-rust-app.git \u0026\u0026 cd yugabyte-simple-rust-app\n```\n\n## Provide Cluster Connection Parameters\n\nUpdate the following connection parameters in the `src/sample-app.rs` file:\n* `HOST` - the hostname of your instance.\n* `USER` - the username for your instance.\n* `PASSWORD` - the database password.\n* `SSL_MODE`  - make sure it's set to `SslMode::Require` for YugabyteDB Aeon.\n* `SSL_ROOT_CERT` - a full path to your CA root cert (for example, `/Users/dmagda/certificates/root.crt`). \n\nNote, you can easily find all the settings on the YugabyteDB Aeon dashboard:\n\n![image](resources/cloud_app_settings.png)\n\n## Run the Application\n \nBuild and run the application:\n```bash\ncargo run\n```\n\nThe Rust PostgreSQL driver will be installed automatically during the first execution of the command. The driver is listed in the dependencies list of the `Cargo.toml` file.\n\nUpon successful execution, you will see output similar to the following:\n\n```bash\n\u003e\u003e\u003e\u003e Connecting to YugabyteDB!\n\u003e\u003e\u003e\u003e Successfully connected to YugabyteDB!\n\u003e\u003e\u003e\u003e Successfully created table DemoAccount.\n\u003e\u003e\u003e\u003e Selecting accounts:\nname = Jessica, age = 28, country = USA, balance = 10000\nname = John, age = 28, country = Canada, balance = 9000\n\u003e\u003e\u003e\u003e Transferred 800 between accounts\n\u003e\u003e\u003e\u003e Selecting accounts:\nname = Jessica, age = 28, country = USA, balance = 9200\nname = John, age = 28, country = Canada, balance = 9800\n```\n\n## Explore Application Logic\n\nCongrats! You've successfully executed a simple Rust app that works with YugabyteDB.\n\nNow, explore the source code of `src/sample-app.rs`:\n1. `connect` function - establishes a connection with your cloud instance via the Rust PostgreSQL driver.\n2. `create_database` function - creates a table and populates it with sample data.\n3. `select_accounts` function - queries the data with SQL `SELECT` statements.\n4. `transfer_money_between_accounts` function - updates records consistently with distributed transactions.\n\n## Questions or Issues?\n\nHaving issues running this application or want to learn more from Yugabyte experts?\n\nJoin [our Slack channel](https://communityinviter.com/apps/yugabyte-db/register),\nor raise a question on StackOverflow and tag the question with `yugabytedb`!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugabytedb-samples%2Fyugabyte-simple-rust-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyugabytedb-samples%2Fyugabyte-simple-rust-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugabytedb-samples%2Fyugabyte-simple-rust-app/lists"}