{"id":21042716,"url":"https://github.com/yugabytedb-samples/yugabytedb-rust-examples","last_synced_at":"2026-04-15T06:39:07.530Z","repository":{"id":161448998,"uuid":"511115897","full_name":"YugabyteDB-Samples/yugabytedb-rust-examples","owner":"YugabyteDB-Samples","description":"Rust examples for the usage of YugabyteDB.","archived":false,"fork":false,"pushed_at":"2023-04-07T17:31:37.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-02T18:29:26.896Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"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":null,"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-07-06T11:50:27.000Z","updated_at":"2023-03-10T23:12:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"80aceb4b-f51f-4028-b589-1cb087c11f41","html_url":"https://github.com/YugabyteDB-Samples/yugabytedb-rust-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/YugabyteDB-Samples/yugabytedb-rust-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabytedb-rust-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabytedb-rust-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabytedb-rust-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabytedb-rust-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/YugabyteDB-Samples","download_url":"https://codeload.github.com/YugabyteDB-Samples/yugabytedb-rust-examples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/YugabyteDB-Samples%2Fyugabytedb-rust-examples/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31830156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"online","status_checked_at":"2026-04-15T02:00:06.175Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-19T14:08:46.807Z","updated_at":"2026-04-15T06:39:07.495Z","avatar_url":"https://github.com/YugabyteDB-Samples.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rust examples for YugabyteDB\n\n## YSQL\n\n### Smart driver currently not available\nCurrently, YugabyteDB YSQL alias the PostgreSQL API does not have a YugabyteDB YSQL specific smart driver.\nNot having a YSQL smart driver is not an issue for regular database usage, because YSQL tries to stay as close as possible to PostgreSQL,\nand therefore the standard PostgreSQL drivers fully work with YugabyteDB YSQL.\n\nHowever, this means that the YugabyteDB specific features that are in the JDBC driver are currently not available in the driver.\nThese functions are:\n- Multiple hosts. To avoid having a single node for the initial connection.\n- Cluster awareness. To enable uniform load balancing.\n- Topology awareness. To be able to distribute connections using the topology decoration (cloud, region, zone).\n- Configurable cluster topology refresh interval.\n\nTo express your interest for a Rust smart driver please share your interest with this [issue](https://github.com/yugabyte/yugabyte-db/issues/16657).\n\n### pgcat (smart driver alternative)\nHowever, there is a (next best) Rust based solution: [pgcat](https://github.com/postgresml/pcat).  \n\nPgcat is a PostgreSQL pooler like PgBouncer, but adds features.\nThe main feature to overcome the absence of a native YugabyteDB YSQL driver, load balance new connections over multiple database endpoints, \ncan be achieved by using pgcat as a front-end or backend-end proxy/pooler.\n\nSee [this](https://dev.to/yugabyte/pgcat-a-postgresql-pooler-3a24) article on how to configure pgcat for connection distribution over YugabyteDB YSQL cluster endpoints.\n\n### postgres\n[Cargo project with examples](postgres)\n### diesel\n[Cargo project with examples](diesel)\n### sqlx\n[Cargo project with examples](sqlx)\n\n## YCQL\n### cassandra-cpp with the Yugabyte C++ driver\nThe cassandra-cpp driver for Rust uses the Cassandra C++ driver, and uses the functions in it via the Rust FFI (foreign functions interface).\nThe way the cassandra-cpp driver crate works is that it actually is a wrapper around the raw driver binding crate cassandra-cpp-sys, which provides the actual bindings.\nThe bindings use the functions provided by the libcassandra (C++) library.\n\n#### driver installation\n##### OSX\n```shell\nbrew install autoconf automake cmake libtool libuv openssl zlib git\ngit clone https://github.com/yugabyte/cassandra-cpp-driver.git\ncd cassandra-cpp-driver\nmkdir build\npushd build\ncmake ..\nmake\nmake install\npopd\n```\nThe `make install` command installs the driver (libcassandra.dylib) in `/usr/local/lib`.\n##### Linux (EL)\nEL7 (validated with Centos 7)\n```shell\nsudo yum install automake cmake gcc-c++ git libtool openssl-devel zlib-devel\nsudo yum install https://downloads.datastax.com/cpp-driver/centos/7/dependencies/libuv/v1.35.0/libuv-1.35.0-1.el7.x86_64.rpm\nsudo yum install https://downloads.datastax.com/cpp-driver/centos/7/dependencies/libuv/v1.35.0/libuv-devel-1.35.0-1.el7.x86_64.rpm\ngit clone https://github.com/yugabyte/cassandra-cpp-driver.git\ncd cassandra-cpp-driver\nmkdir build\npushd build\ncmake ..\nmake\nsudo make install\npopd\n```\nThe `make install` command install the driver (libcassandra.so) in `/usr/local/lib64`.\nIn order to make the dynamic loader find the library add the directory to the LD_LIBRARY_PATH environment variable:\n```shell\nexport LD_LIBRARY_PATH=/usr/local/lib64\n```\nThe error that is shown when the libcassandra.so driver is not in the path is:\n```\ntarget/debug/examples/local: error while loading shared libraries: libcassandra.so.2: cannot open shared object file: No such file or directory\n```\n##### Linux (EL)\nEL8 (validated with Alma 8)\n```shell\nsudo yum install automake cmake gcc-c++ git libtool openssl-devel zlib-devel\nsudo yum install https://downloads.datastax.com/cpp-driver/centos/8/dependencies/libuv/v1.35.0/libuv-1.35.0-1.el8.x86_64.rpm\nsudo yum install https://downloads.datastax.com/cpp-driver/centos/8/dependencies/libuv/v1.35.0/libuv-devel-1.35.0-1.el8.x86_64.rpm\ngit clone https://github.com/yugabyte/cassandra-cpp-driver.git\ncd cassandra-cpp-driver\nmkdir build\npushd build\ncmake ..\nmake\nsudo make install\npopd\n```\nThe `make install` command installs the driver (libcassandra.so) in `/usr/local/lib64`, which is not in the default library path.\nIn order to make the dynamic loader find the library add the directory to the LD_LIBRARY_PATH environment variable:\n```shell\nexport LD_LIBRARY_PATH=/usr/local/lib64\n```\nThe error that is shown when the libcassandra.so driver is not in the path is:\n```\ntarget/debug/examples/local: error while loading shared libraries: libcassandra.so.2: cannot open shared object file: No such file or directory\n```\n[Cargo project with examples](cassandra-cpp).\n\n----\n### cassandra-cpp with the DataStax C++ driver\nThe cassandra-cpp driver for Rust uses the Cassandra C++ driver, and uses the functions in it via the Rust FFI (foreign function interface).\nThe way the cassandra-cpp driver crate works is that it actually is a wrapper around the raw driver binding crate cassandra-cpp-sys, which provides the actual bindings.\nThe bindings use the functions provided by the libcassandra (C++) library.\n\n#### driver installation\n##### OSX\n```shell\nbrew install cassandra-cpp-driver openssl\n```\n##### Linux (EL)\nEL8 (validated with Alma 8):\n```shell\nyum install https://downloads.datastax.com/cpp-driver/centos/8/cassandra/v2.16.0/cassandra-cpp-driver-2.16.0-1.el8.x86_64.rpm\n```\nEL7 (validated with Centos 7):\n```shell\nyum install https://downloads.datastax.com/cpp-driver/centos/7/cassandra/v2.16.0/cassandra-cpp-driver-2.16.0-1.el7.x86_64.rpm\n```\n[Cargo project with examples](cassandra-cpp).  \n\n----\n### scylla\nThe scylla driver for Rust is a 'pure rust' driver, meaning it has no non-rust dependencies.  \nThe scylla driver is an asynchronous driver.  \nThe driver obviously is created for the Scylla database, but it can also be used for any Cassandra compatible database.  \n[Cargo project with examples](scylla).\n\n---\n# WARNING\nBelow are crates that are available, but are not active or do lack reasonable SSL support.\n\n### cdrs\nThe cdrs driver for Rust is a 'pure rust' driver, meaning it has no non-rust dependencies.  \n[Cargo project with examples](cdrs).  \nWarning: the cdrs driver project asks for a new maintainer, and looks inactive.\n\n### cdrs-tokio\nThe cdrs-tokio driver for Rust is a 'pure rust' driver, meaning it has no non-rust dependencies.  \n[Cargo project with examples](cdrs_tokio)\nWarning: the cdrs-tokio driver project looks active, but seems to lack SSL/TLS support.  \n(tls support is a feature, which is not documented and throws crate version compatibility issues)\n\n### cassandra\nThe cassandra crate is the original crate with bindings to the cassandra c++ driver, but has been abandoned.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugabytedb-samples%2Fyugabytedb-rust-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyugabytedb-samples%2Fyugabytedb-rust-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugabytedb-samples%2Fyugabytedb-rust-examples/lists"}