Giter Site home page Giter Site logo

akita's Introduction

Akita   Build Status Latest Version akita: rustc 1.13+ akita_derive: rustc 1.31+

Akita - Mini orm for rust with SQLite & MySQL.

This create offers:

  • MySql database's helper in pure rust;
  • SQLite database's helper in pure rust;
  • A mini orm framework (With MySQL/SQLite)。

Features:

  • Other Database support, i.e. support Oracle, MSSQL...;
  • support of named parameters for custom condition;

You may be looking for:

Akita in action

Click to show Cargo.toml. Run this code in the playground.
[dependencies]

# The core APIs, including the Table traits. Always
# required when using Akita. using #[derive(Table)] 
# to make Akita work with structs defined in your crate.
akita = { version = "0.3.0"] }

use akita::*;
use akita::prelude::*;

/// Annotion Support: Table、table_id、field (name, exist)
#[derive(Debug, FromAkita, ToAkita, Table, Clone)]
#[table(name="t_system_user")]
struct SystemUser {
    #[field = "name"]
    id: Option<i32>,
    #[table_id]
    username: String,
    /// ⚠️ When exist is set to false, the type must be defined as option
    #[field(name="ages", exist = "false")]
    age: i32,
}

fn main() {
    let db_url = String::from("mysql://root:password@localhost:3306/akita");
    let cfg = AkitaConfig::new(db_url);
    cfg.set_max_size(16).set_connect_timeount(Duration::from_secs(5));
    let mut pool = Pool::new(cfg).unwrap();
    let mut em = pool.entity_manager().expect("must be ok");
    let mut wrap = UpdateWrapper::new();
    wrap.eq(true, "username", "'ussd'");
    match em.count::<SystemUser, UpdateWrapper>(&mut wrap) {
        Ok(res) => {
            println!("success count data!");
        }
        Err(err) => {
            println!("error:{:?}",err);
        }
    }
}

Feature.

  • akita-mysql - to use mysql
  • akita-sqlite - to use sqlite

Annotions.

  • Table - to make Akita work with structs
  • table_id - to make Table Ident
  • field - to make struct field with own database.
  • name - work with column, make the table's field name. default struct' field name.
  • exist - ignore struct's field with table. default true.

Support Field Types.

  • Option<T>
  • u8, u32, u64
  • i32, i64
  • usize
  • bool
  • f32, f64
  • str, String
  • serde_json::Value
  • NaiveDate, NaiveDateTime

Developing

To setup the development envrionment run cargo run.

Contributers

Getting help

Akita is a personal project. At the beginning, I just like Akita dog because of my hobbies. I hope this project will grow more and more lovely. Many practical database functions will be added in the future. I hope you can actively help this project grow and put forward suggestions. I believe the future will be better and better.


License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Akita by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

akita's People

Contributors

wslongchen avatar vincascm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.