3 Star 21 Fork 9

brinkqiang/dmorm

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

dmorm

Copyright (c) 2013-2018 brinkqiang (brink.qiang@gmail.com)

Build status

Linux Windows
lin-badge win-badge

简体中文 · English

Intro

dmorm

用法

dmormtest -user=root -pass=000000

1. windows

修改src/person.proto 执行build_person.bat即可 person.orm.h 为自动生成的orm映射文件.
命令行安装好cmake之后执行build.bat 即可生成vs工程
注意: thirdparty/mysql下面的库为WIN64 如需WIN32请自行下载

2. linux

修改src/person.proto 执行build_person.sh即可 person.orm.h 为自动生成的orm映射文件.
直接bash build.sh即可

3. 生成工具dmgen4pborm

dmgen4pborm --cpp_out=. person.proto


#include <iostream>
#include "dmgdb.hpp"
#include "person.orm.h"
#include "dmsnowflake.h"
#include "dmflags.h"

uint64_t NextID()
{
    static CDMIDGenerator gGen(0, 0);
    return gGen.GetNextID();
}

DEFINE_string(ip, "127.0.0.1", "127.0.0.1");
DEFINE_string(user, "root", "root");
DEFINE_string(pass, "000000", "000000");
DEFINE_int32(port, 3306, "3306");

int main(int argc, char** argv)
{
    DMFLAGS_INIT(argc, argv);

    GDb oGDB(FLAGS_ip, FLAGS_port, FLAGS_user, FLAGS_pass);
    oGDB.init("");

    DBQuery oQuery;

    db_CreateTable(oGDB, oQuery);

    CDMPB_tb_Person oPerson(oGDB, oQuery);

    db::tb_Person data;
    data.set_id(NextID());
    data.set_number("13900112233");
    data.set_email("person@163.com");
    data.set_phonetype(::db::PhoneType::WORK);

    oPerson.Insert(data);

    {
        std::vector<db::tb_Person> datas;
        oPerson.Select(data, datas);

        for (int i = 0; i < datas.size(); ++i)
        {
            std::cout << datas[i].DebugString() << std::endl;
        }
    }
    db::tb_Person data2;
    data2.set_id(data.id());
    data2.set_number("123456789");

    oPerson.Update(data2);

    db::tb_Person data3;
    data3.set_id(NextID());
    data3.set_number("13655265368");
    data3.set_email("tom@qq.com");
    data3.set_phonetype(::db::PhoneType::WORK);

    oPerson.Insert(data3);
    {
        std::vector<db::tb_Person> datas;
        oPerson.Select(datas);
        for (int i = 0; i < datas.size(); ++i)
        {
            std::cout << datas[i].DebugString() << std::endl;
        }
    }

    oPerson.Del(data);

    {
        std::vector<db::tb_Person> datas;
        oPerson.Select(data, datas);
        for (int i = 0; i < datas.size(); ++i)
        {
            std::cout << datas[i].DebugString() << std::endl;
        }
    }

    fmt::print("Done\n");
    return 0;
}

Thanks

MIT License Copyright (c) 2018 brinkqiang (brink.qiang@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于 protobuf 的 C++ ORM 框架, 通过.proto文件生成C++ SQL操作代码. 展开 收起
C++ 等 5 种语言
MIT
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/brinkqiang/dmorm.git
git@gitee.com:brinkqiang/dmorm.git
brinkqiang
dmorm
dmorm
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891