Giter VIP home page Giter VIP logo

cpp-sqlite-template's Introduction

Sqlite template for c++

Back Story

When i was looking for database for my project. i was thinking to implement Mysql and i found out it was quite hard to setup and use in c++.
Then i found sqlite for c++ article i read about it and i came up with this template.

I Will try to create step by step tutorial about it.

This template design for small projects only but you can modify a your need

I try to make things simple as possible.

  • db : On this folder we will store all our databases
  • sqlite : this folder contains sqlite header file.

NOTE : You can move into header file folder if it is large projects and have lots of library

  • src : It consists of all cpp files
  • main.cpp : here you write your codes.

Example Code

#include <iostream> 
#include "sqlite/sqlite3.h"

using namespace std;
  
int main() 
{ 
    // Pointer to SQLite connection
    sqlite3* db; 
    
    // Save the connection result
    int exit = 0;
    exit = sqlite3_open("db/example.db", &db); 
  
    // Test if there was an error
    if (exit) { 
        
        cout << "DB Open Error: " << sqlite3_errmsg(db) << endl; 
        
    } else {

        cout << "Opened Database Successfully!" << endl; 
    }
    
    // Close the connection
    sqlite3_close(db); 
    
    return (0); 
}

Then we have MakeFile

compile:
		g++ main.cpp -o main -l sqlite3

		./main

How to Run ?

Open up your terminal and type following

mingw32-make -f MakeFile

Or we can use second option

type following on terminal

g++ main.cpp -o main -l sqlite3

MakeFile make things lot easier ** I recommend MakeFile **

Happy Coding ๐Ÿ™‚
Keep Learning ๐Ÿ“– \

cpp-sqlite-template's People

Contributors

diwacreation3 avatar

Stargazers

Aaryaman Adhikari avatar

Watchers

 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.