Skip to content

mlach9u/sqlitemp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Template classes for SQLite (SQLitemp)


License

This is in the Public Domain.

Purpose

  1. Wrapper classes of SQLite
  2. Use SQLite with STL

Usage

Open database

Use open function

sqliteDatabase db;
db.open(filename);

Use contructor

sqliteDatabase db(filename);

Query

  • execute and query functions are separated.
  • execute is used for INSERT or UPDATE, etc...
  • query is used for SELECT, etc...

Execute query

if (db.execute("INSERT INTO sqlitemp_table (name, age) VALUES ('Dylan Kim', 30)"))
    std::cout << "Succeeded" << std::endl;
else
    std::cout << "Failed" << std::endl;

Select query

sqliteDatabase::rowset_ptr prs = db.query("SELECT * FROM sqlitemp_table");
if (prs.get() && db.good())
{
    sqliteColumnSet cs = prs->column();
    int nSize = cs.size();
    for (int i = 0; i < nSize; i++)
        std::cout << cs.at(i).name() << "\t";
    std::cout << std::endl;
    do
    {
        cs = prs->column();
        for (int i = 0; i < nSize; i++)
            std::cout << cs.at(i) << "\t";
        std::cout << std::endl;
    } while (prs->to_next());
}

About

Template classes for SQLite

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages