Skip to content

helloworldyuhaiyang/sql-builder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

帮助简单的写 sql 语句。

    #demo 在 test 目录下。单元测试依赖 gtest

安装[Linux/Mac]

1.mkdir build 2.cd build 3.cmake .. 4.make 5.make install #安装 [windows/Visual Studio] 1、CMake GUI配置VS 工程文件 2、VS打开右键生成 Debug、Release不同版本的静态库

使用

 InsertModel i;
    i.insert("score", 100)
            ("name", std::string("yu"))
            ("age", 28)
            ("address", nullptr)
            ("create_time", "2016-03-25 10:15:59")
    into("user");
 std::cout << i.str() << std::endl;

  DeleteModel d;
    d._delete()
            .from("user")
            .where(Column("id") == 1);
  std::cout << d << std::endl;

 updateModel.update("user")
            .set("name", "yu")
                    ("age", 18)
                    ("score", 50)
                    ("address", nullptr)
            .where(Column("id").in(a));
 std::cout << updateModel << std::endl;

 sql.select("id", "age", "name", "address")
            .from("user")
            .where(Column("score") > 60 and (Column("age") >= 20 or Column("address").is_not_null()))
            .group_by("age")
            .having(Column("age") > 10)
            .order_by("age desc")
            .limit(10)
            .offset(1);

    std::cout << sql << std::endl;

About

SQL query string builder for C++11

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 92.6%
  • CMake 7.4%