Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

C++ example #107

Open
sunnyb75 opened this issue Sep 16, 2020 · 3 comments
Open

C++ example #107

sunnyb75 opened this issue Sep 16, 2020 · 3 comments

Comments

@sunnyb75
Copy link

Can you provide a C++ example/demo to use with RedisSQL module?

@siscia
Copy link
Collaborator

siscia commented Sep 16, 2020

Hello,

Do you have a specific library in mind?

The API for hiredis that is the official C library is quite small and terse, at least for synchronous API.

It is not tested, but I would do something like:

redisContext *c = redisConnect("127.0.0.1", 6379);
redisCommand(redisContext, "REDISQL.CREATE_DB DB");

redisCommand(redisContext, "REDISQL.EXEC DB 'create table foo (a, b, c);' ");
redisCommand(redisContext, "REDISQL.EXEC DB 'insert into foo values(1,2,3),(4,5,6);' ");
reply = redisCommand(redisContext, "REDISQL.EXEC DB 'select * from foo' ");

// somehow use this reply object
freeReplyObject(reply); // not sure it is needed

It is just a sketch that I didn't test.

Does it helps?

@siscia
Copy link
Collaborator

siscia commented Sep 16, 2020

(And congrats on opening our first issue!)

@nqf
Copy link

nqf commented Sep 18, 2020

you can use redis-plus-plus lib

auto pipe = redis-plus-plus->pipeline(false);
pipe.command("REDISQL.CREATE_DB", "TT")
    .command("REDISQL.EXEC", "TT", "COMMAND", "CREATE TABLE foo(name TEXT);")
    .command("REDISQL.EXEC", "TT", "COMMAND", "CREATE INDEX foo_index ON foo(name);")
    .command("REDISQL.EXEC", "TT", "COMMAND", "INSERT INTO foo VALUES("hello")
    .exec();

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants