{"id":13439086,"url":"https://github.com/ivanceras/rustorm","last_synced_at":"2025-04-04T07:06:51.222Z","repository":{"id":45867493,"uuid":"114145293","full_name":"ivanceras/rustorm","owner":"ivanceras","description":"an orm for rust","archived":false,"fork":false,"pushed_at":"2021-03-06T04:27:01.000Z","size":3126,"stargazers_count":250,"open_issues_count":6,"forks_count":23,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-10-30T03:41:46.225Z","etag":null,"topics":["database","orm","postgresql","rust","sqlite"],"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/ivanceras.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"patreon":"ivanceras","open_collective":"ivanceras"}},"created_at":"2017-12-13T16:44:02.000Z","updated_at":"2024-06-13T13:42:16.000Z","dependencies_parsed_at":"2022-09-14T13:00:26.969Z","dependency_job_id":null,"html_url":"https://github.com/ivanceras/rustorm","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanceras%2Frustorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanceras%2Frustorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanceras%2Frustorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanceras%2Frustorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivanceras","download_url":"https://codeload.github.com/ivanceras/rustorm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135144,"owners_count":20889421,"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":["database","orm","postgresql","rust","sqlite"],"created_at":"2024-07-31T03:01:11.002Z","updated_at":"2025-04-04T07:06:51.199Z","avatar_url":"https://github.com/ivanceras.png","language":"Rust","readme":"[![Build Status](https://travis-ci.org/ivanceras/rustorm.svg?branch=master)](https://travis-ci.org/ivanceras/rustorm)\n\n# rustorm\n\n\n### Rustorm\n\n[![Financial Contributors on Open Collective](https://opencollective.com/rustorm/all/badge.svg?label=financial+contributors)](https://opencollective.com/rustorm) [![Latest Version](https://img.shields.io/crates/v/rustorm.svg)](https://crates.io/crates/rustorm)\n[![Build Status](https://travis-ci.org/ivanceras/rustorm.svg?branch=master)](https://travis-ci.org/ivanceras/rustorm)\n[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\nRustorm is an SQL-centered ORM with focus on ease of use on conversion of database types to\ntheir appropriate rust type.\n\nSelecting records\n\n```rust\nuse rustorm::{\n    DbError,\n    FromDao,\n    Pool,\n    ToColumnNames,\n    ToTableName,\n};\n\n#[derive(Debug, FromDao, ToColumnNames, ToTableName)]\nstruct Actor {\n    actor_id: i32,\n    first_name: String,\n}\n\n#[cfg(any(feature=\"with-postgres\", feature = \"with-sqlite\"))]\nfn main() {\n    let mut pool = Pool::new();\n    #[cfg(feature = \"with-sqlite\")]\n    let db_url = \"sqlite://sakila.db\";\n    #[cfg(feature = \"with-postgres\")]\n    let db_url = \"postgres://postgres:p0stgr3s@localhost/sakila\";\n    let em = pool.em(db_url).unwrap();\n    let sql = \"SELECT * FROM actor LIMIT 10\";\n    let actors: Result\u003cVec\u003cActor\u003e, DbError\u003e =\n        em.execute_sql_with_return(sql, \u0026[]);\n    println!(\"Actor: {:#?}\", actors);\n    let actors = actors.unwrap();\n    assert_eq!(actors.len(), 10);\n    for actor in actors {\n        println!(\"actor: {:?}\", actor);\n    }\n}\n#[cfg(feature=\"with-mysql\")]\nfn main() {\n   println!(\"see examples for mysql usage, mysql has a little difference in the api\");\n}\n```\nInserting and displaying the inserted records\n\n```rust\nuse chrono::{\n    offset::Utc,\n    DateTime,\n    NaiveDate,\n};\nuse rustorm::{\n    DbError,\n    FromDao,\n    Pool,\n    TableName,\n    ToColumnNames,\n    ToDao,\n    ToTableName,\n};\n\n\n#[cfg(any(feature=\"with-postgres\", feature = \"with-sqlite\"))]\nfn main() {\n    mod for_insert {\n        use super::*;\n        #[derive(Debug, PartialEq, ToDao, ToColumnNames, ToTableName)]\n        pub struct Actor {\n            pub first_name: String,\n            pub last_name: String,\n        }\n    }\n\n    mod for_retrieve {\n        use super::*;\n        #[derive(Debug, FromDao, ToColumnNames, ToTableName)]\n        pub struct Actor {\n            pub actor_id: i32,\n            pub first_name: String,\n            pub last_name: String,\n            pub last_update: DateTime\u003cUtc\u003e,\n        }\n    }\n\n    let mut pool = Pool::new();\n    #[cfg(feature = \"with-sqlite\")]\n    let db_url = \"sqlite://sakila.db\";\n    #[cfg(feature = \"with-postgres\")]\n    let db_url = \"postgres://postgres:p0stgr3s@localhost/sakila\";\n    let em = pool.em(db_url).unwrap();\n    let tom_cruise = for_insert::Actor {\n        first_name: \"TOM\".into(),\n        last_name: \"CRUISE\".to_string(),\n    };\n    let tom_hanks = for_insert::Actor {\n        first_name: \"TOM\".into(),\n        last_name: \"HANKS\".to_string(),\n    };\n\n    let actors: Result\u003cVec\u003cfor_retrieve::Actor\u003e, DbError\u003e =\n        em.insert(\u0026[\u0026tom_cruise, \u0026tom_hanks]);\n    println!(\"Actor: {:#?}\", actors);\n    assert!(actors.is_ok());\n    let actors = actors.unwrap();\n    let today = Utc::now().date();\n    assert_eq!(tom_cruise.first_name, actors[0].first_name);\n    assert_eq!(tom_cruise.last_name, actors[0].last_name);\n    assert_eq!(today, actors[0].last_update.date());\n\n    assert_eq!(tom_hanks.first_name, actors[1].first_name);\n    assert_eq!(tom_hanks.last_name, actors[1].last_name);\n    assert_eq!(today, actors[1].last_update.date());\n}\n#[cfg(feature=\"with-mysql\")]\nfn main() {\n   println!(\"see examples for mysql usage, mysql has a little difference in the api\");\n}\n```\nRustorm is wholly used by [diwata](https://github.com/ivanceras/diwata)\n\nLicense: MIT\n\n## Contributors\n\n### Code Contributors\n\nThis project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].\n\u003ca href=\"https://github.com/ivanceras/rustorm/graphs/contributors\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/contributors.svg?width=890\u0026button=false\" /\u003e\u003c/a\u003e\n\n### Financial Contributors\n\nBecome a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/rustorm/contribute)]\n\n#### Individuals\n\n\u003ca href=\"https://opencollective.com/rustorm\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/individuals.svg?width=890\"\u003e\u003c/a\u003e\n\n#### Organizations\n\nSupport this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/rustorm/contribute)]\n\n\u003ca href=\"https://opencollective.com/rustorm/organization/0/website\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/organization/0/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rustorm/organization/1/website\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/organization/1/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rustorm/organization/2/website\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/organization/2/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rustorm/organization/3/website\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/organization/3/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rustorm/organization/4/website\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/organization/4/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rustorm/organization/5/website\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/organization/5/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rustorm/organization/6/website\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/organization/6/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rustorm/organization/7/website\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/organization/7/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rustorm/organization/8/website\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/organization/8/avatar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/rustorm/organization/9/website\"\u003e\u003cimg src=\"https://opencollective.com/rustorm/organization/9/avatar.svg\"\u003e\u003c/a\u003e\n","funding_links":["https://patreon.com/ivanceras","https://opencollective.com/ivanceras","https://opencollective.com/rustorm","https://opencollective.com/rustorm/contribute","https://opencollective.com/rustorm/organization/0/website","https://opencollective.com/rustorm/organization/1/website","https://opencollective.com/rustorm/organization/2/website","https://opencollective.com/rustorm/organization/3/website","https://opencollective.com/rustorm/organization/4/website","https://opencollective.com/rustorm/organization/5/website","https://opencollective.com/rustorm/organization/6/website","https://opencollective.com/rustorm/organization/7/website","https://opencollective.com/rustorm/organization/8/website","https://opencollective.com/rustorm/organization/9/website"],"categories":["Libraries","Rust","库 Libraries","库"],"sub_categories":["Database","数据库 Database","数据库"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanceras%2Frustorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivanceras%2Frustorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanceras%2Frustorm/lists"}