Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Sébastien Rombauts
    @SRombauts
    Welcome to the discussion!
    Jack.Yuan
    @HighSparrow
    Hi
    Sébastien Rombauts
    @SRombauts
    Hello!
    Jack.Yuan
    @HighSparrow
    Please add my Skype jackyuan_bb@hotmail.com, thank you. I am not using gitter.
    Sooraj
    @sooorajjj
    Hello

    SQlitecpp: fails to fetch data from database
    Here is how my code looks

    lk_dispclr();                                 
    strcpy(menu.title,"Login");
    
    int res=0;
    prn_open();
    
    lk_bkl_timeout(20);
    lk_dispclr();
    lcd::DisplayText(1,0,"1.User Menu ",0);
    lcd::DisplayText(4,0,"Press any key",0);
    lk_getkey();
    
    while(1)
    {
        char user[10]={0};
        lk_dispclr();
        lcd::DisplayText(2,0,"Enter Username",0);
        res=lk_getalpha(4,0,(unsigned char *)user,9,strlen(user),0);
        if(res>0)
        {
            user[res]='\0';
    
            printf("Username is %s %d\n",user,res);
            klok::pc::User userObj;
            if(klok::pc::User::FromDatabase(getDatabase(),user,userObj) != 0)
            {
                printf("No Such User %s\n", user);
                continue;
            }
            if(userObj.id == user)
            {
                while(1)
                {
                    char pwd[10]={0};
                    lk_dispclr();
                    lcd::DisplayText(2,0,"Enter Password",0);
                    res=lk_getpassword((unsigned char *)pwd,4,9);
                    if (res>0)
                    {
                        pwd[res]='\0';
                        printf("Password is %s %d\n",pwd,res);
                        if(userObj.password == pwd )
                        {
                            gUserName = user;
                            main_menu(user,pwd);
                            printf("main_menu\n");
                        }
                        else
                        {
                            goto AGAIN_ASK_USER_DETAILS;
                        }
                    }
                }
            }
        }

    AGAIN_ASK_USER_DETAILS:
    while(false);
    }

    Database helper

    include "PosDataStructures.hpp"

    include <SQLiteCpp/SQLiteCpp.h>

    namespace klok {
    namespace pc {

            namespace {
    
                using SQLite::Database;
                using SQLite::Column;
                using SQLite::Statement;
    
            }
    
            int32_t User::FromDatabase(SQLite::Database & db,const char * id,User & outUser){
    
                const std::string queryString = "SELECT * FROM ? WHERE User_ID=?";
                try
                {
                    SQLite::Statement query(db,User::Queries::SELECT_USER_WITH_ID_FROM_TABLE);
                    query.bind(1,User::Queries::TABLE_NAME);
                    query.bind(2,id);
    
                    if(query.executeStep())
                    {
                        outUser.id = query.getColumn(0).getString();
                        outUser.name = query.getColumn(1).getString();
                        outUser.password = query.getColumn(2).getString();
                        return 0;
                    }
                    else
                    {
                        return -1;
                    }
                }
                catch(std::exception & e)
                {
                    std::printf("User::FromDatabase -> Fatal Error %s\n", e.what());
                    return -1;
                }
    
                return 0;
            }
    
            int32_t User::CreateTable(SQLite::Database & db,bool dropIfExist){
                const std::string queryString = "SELECT * FROM pay_coll_user WHERE User_ID=?";
                try
                {
                    SQLite::Statement query(db,queryString);
                    if(query.executeStep()) {
                        return 0;
                    }
                    else {
                        return -1;
                    }
                }
                catch(std::exception & e)
                {
                    std::printf("User::CreateTable -> Fatal Error %s\n", e.what());
                    return -1;
                }
    
                return 0;
            }
            const char * User::Queries::TABLE_NAME = "pay_coll_user";
            const char * User::Queries::SELECT_USER_WITH_ID_FROM_TABLE = "SELECT * FROM ? WHERE User_ID=?";
            const char * User::Queries::DROP_USER_TABLE_QUERY = "DROP TABLE ? IF EXISTS;";
    }
    }
    can anyone help me with this
    @everyone @SRombauts
    Sooraj
    @sooorajjj
    @giumas @MariadeAnton
    Nicholas Hallahan
    @hallahan
    Hi @everyone ! I'm new to CMake, and I was wondering if there is a simple example where I can see how to add SQLiteCpp to another CMake project. That CMake project does build in OS X, Ubuntu, iOS, Android
    Butitsnotme
    @butitsnotme
    If not one provides anything more official, you can take a look at (this CMakeLists.txt)[https://github.com/butitsnotme/bground/blob/master/CMakeLists.txt], from a project I did. You'll also want to look at (this auxiliary one)[https://github.com/butitsnotme/bground/blob/master/src/CMakeLists.txt], which is where the linking occurs.
    No one*
    Sébastien Rombauts
    @SRombauts
    I do have an example project here: https://github.com/SRombauts/SQLiteCpp_Example
    sorry for not beeing reactive guys
    I have started a new job 5 months ago, and I have been fully under the water until now
    (gamedev job)
    Andrew Durkiewicz
    @andrewdurkiewicz
    I have a general question about the SQLiteCpp database. Are database objects automatically freed from memory?
    Sébastien Rombauts
    @SRombauts
    Yes, the Database destructor automatically close the underlying db