Skip to content

how to use the libchdb.so in c/c++ code? #347

Answered by wudidapaopao
l1t1 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @l1t1, to use libchdb.so, you only need the chdb.h header file and the compiled shared library libchdb.so. You don't need the rest of the source code if you're just using the library.

Below is a simple example in C that demonstrates how to use chdb.h together with libchdb.so:

#include <stdio.h>
#include <stdlib.h>
#include "chdb.h"

int main(void) {
    // 1. Prepare connection arguments
    // Session will keep the state of query.
    // If path is None, it will create a temporary directory and use it as the database path
    // and the temporary directory will be removed when the session is closed.
    // You can also pass in a path to create a database at that path where will keep y…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by l1t1
Comment options

You must be logged in to vote
2 replies
@wudidapaopao
Comment options

@auxten
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants