{"id":19902590,"url":"https://github.com/johnbasrai/rust-sqlx","last_synced_at":"2026-05-18T00:08:22.233Z","repository":{"id":199060641,"uuid":"702066628","full_name":"JohnBasrai/rust-sqlx","owner":"JohnBasrai","description":"Async PostgreSQL database access in Rust using SQLx and Tokio. Demonstrates how to insert and update PostgreSQL enum columns using Rust enums and sqlx","archived":false,"fork":false,"pushed_at":"2025-04-29T15:06:56.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-27T06:08:03.868Z","etag":null,"topics":["postgresql","sqlx-postgres","tokio"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JohnBasrai.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,"zenodo":null}},"created_at":"2023-10-08T11:53:38.000Z","updated_at":"2025-04-29T17:10:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"90170a1d-a3a7-4a0f-8725-f8e99e3e6514","html_url":"https://github.com/JohnBasrai/rust-sqlx","commit_stats":null,"previous_names":["johnbasrai/rust-sqlx"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/JohnBasrai/rust-sqlx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnBasrai%2Frust-sqlx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnBasrai%2Frust-sqlx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnBasrai%2Frust-sqlx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnBasrai%2Frust-sqlx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JohnBasrai","download_url":"https://codeload.github.com/JohnBasrai/rust-sqlx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JohnBasrai%2Frust-sqlx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33160168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"ssl_error","status_checked_at":"2026-05-17T22:39:10.741Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["postgresql","sqlx-postgres","tokio"],"created_at":"2024-11-12T20:18:34.902Z","updated_at":"2026-05-18T00:08:17.225Z","avatar_url":"https://github.com/JohnBasrai.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rust-sqlx\n\nAsync PostgreSQL database access in Rust using SQLx and Tokio.  This project demonstrates\nhow to insert and update PostgreSQL enum columns using Rust enums and `sqlx`.\n\nAt the time of writing, clear examples for updating enum fields were hard to find. This\ndemo pulls together the correct patterns in a working example. Hopefully it saves others\nsome time and frustration.\n\n***\n\n## Running\n\nBefore running this demo with PostgreSQL (the primary target database), you'll need to\nstart a local PostgreSQL instance.\n\nThe quickest way is to use the official Docker container image:\n\n```bash\ndocker run --rm --network=host --name=postgres \\\n  -e POSTGRES_PASSWORD=welcome \\\n  -e POSTGRES_USER=postgres \\\n  -p 5432:5432 \\\n  postgres\n```\n\nThen, from another shell window, exec into the database container and initialize the schema:\n\n```bash\ndocker exec -i postgres psql --username=postgres \u003c db-init.sql\n```\n\nBack in the first shell window, set the `DATABASE_URL` environment variable and run the application:\n\n```bash\nexport DATABASE_URL=postgres://postgres@localhost:5432/postgres\ncargo run\n```\n\nYou’ll see records being added. Once the table exceeds 10 rows, the program will begin\ndeleting one row for each new insert.\n\n### Sample Output\n\n```text\n----- 1\n----- 2\n----- 3: Record { id: 1 }\n----- 5\n\n== SELECT users with sqlx::query_as!:\n\n   User { id: 1, name: \"Attila the long dead Hun:1\", role: User }\n----- 6\n\n=== SELECT users with query.map..:\n[User { id: 1, name: \"Attila the long dead Hun:1\", role: User }]\n----- 7\n\n=== SELECT users with query.map..:\n[User { id: 1, name: \"Attila the long dead Hun:1\", role: User }]\n```\n\nIf you run again you will see more rows added to the table. When the row count is greater\nthan 10 it will delete 1 row for each row added.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbasrai%2Frust-sqlx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnbasrai%2Frust-sqlx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbasrai%2Frust-sqlx/lists"}