Radikant-SQL-C

Screenshot%202025 11 30%20at%2023.01.45

Radikant SQL is a platform agnostic library that uses Radikant Socket and Radikant Crypto to establish a connection a mySql server. The library currently can queryt and insert data,

Handshake v10

If  not enabled all logging macros expand to empty loops and will be removed from the binary.

mySQL V9.x.x support

Filter debug messages at runtime to prevent verbose screen

Encrypted connection

Abstracts mutex locking to ensure log messages don't get scrambled when accessed by multiple threads.

Select

Define Log Levels, the macros will remove unused logging functions from runtime.

Insert

Use context instances, allow different parts of your program to have different log levels.

Logging

Log to one ore more files as astream simultaneously and independentily withouth any issues

Example

FileEditViewProject
MySQLConnector — Database Init
int main() {
const char *host = "127.0.0.1";
uint16_t port = 3306;
const char *user = "my_app_user";
const char *password = "MyNewPassword123!";
const char *database = "models";
log_info("Connecting to MySQL %s:%u...\n", host, port);
sql_error_t r = sql_connect(ctx, host, port, user, password, database);
return 0;
}
23:32:00 [INFO] Connecting to MySQL 127.0.0.1:3306... 23:32:00 [SUCCES] TCP connection established to 127.0.0.1:3306 23:32:00 [INFO] Parsing HandshakeV10 packet... 23:32:00 [ALERT] Server provided empty auth plugin, defaulting to caching_sha2_password 23:32:00 [INFO] --- Server Info --- 23:32:00 [INFO] Conn ID: 11 23:32:00 [INFO] Auth Plugin: caching_sha2_password 23:32:00 [INFO] Capabilities: 0xDFFFFFFF 23:32:00 [INFO] Salt (hex): 6667432D7261660453072B38100143043704215A

Select

id name city age bio created_at
10Eric JanssenThe Hague41Project manager and jazz enthusiast.2025-11-25 00:56:32
11Fiona SmitsGroningen25Loves painting and hiking.2025-11-25 00:56:32
12Gerrit BakkerMaastricht33Entrepreneur in tech startups.2025-11-25 00:56:32
13Hanna KuiperLeiden29Baker and food blogger.2025-11-25 00:56:32
14Ivo van DijkArnhem38Fitness coach and marathon runner.2025-11-25 00:56:32
15Jasmijn PetersNijmegen26Musician and composer.2025-11-25 00:56:32
16Koen MeijerZwolle31Mechanical engineer and drone hobbyist.2025-11-25 00:56:32
17Lotte de BoerTilburg27Graphic designer and illustrator.2025-11-25 00:56:32
18Martijn VosHaarlem36Teacher of mathematics.2025-11-25 00:56:32
19Nina van LeeuwenBreda24Student and volunteer at animal shelter.2025-11-25 00:56:32

    sql_query(ctx, "SELECT * FROM models.users WHERE name = 'Ivo van Dijk';");
    sql_read_query_result(ctx);
    
19:35:07 [SUCCESS] Database 'models' selected successfully. 19:35:07 [SUCCESS] Connected to MySQL server at 127.0.0.1:3306 19:35:07 [MSG] Sending query: SELECT * FROM models.users WHERE name = 'Ivo van Dijk'; 19:35:07 [ALERT] sql_send_packet tx->sequence_id 0 19:35:07 [SUCCESS] Send packet: len=56, sequence_id=0 19:35:07 HEX SEND PAYLOAD (56 bytes) 0000: 03 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 6d 0010: 6f 64 65 6c 73 2e 75 73 65 72 73 20 57 48 45 52 0020: 45 20 6e 61 6d 65 20 3d 20 27 49 76 6f 20 76 61 0030: 6e 20 44 69 6a 6b 27 3b id | name | city | age | bio | created_at 14 | Ivo van Dijk | Arnhem | 38 | Fitness coach and marathon runner. | 2025-11-25 00:56:32 -------------------------------------------------- Total Rows: 1

Insert

FileEditViewProject
DatabaseTest — SQL Queries
printf("\n--- STEP 0: Count users ---\n");
sql_query(ctx, "SELECT count(*) FROM models.users;");
sql_read_query_result(ctx);
 
printf("\n--- STEP 1: Insert a new user from C ---\n");
sql_query(ctx, "INSERT INTO models.users (name, city, age, bio, created_at) VALUES ('User_From_C', 'CodeCity', 99, 'Born in C', NOW());");
sql_read_query_result(ctx);
 
printf("\n--- STEP 2: Select that specific user ---\n");
sql_query(ctx, "SELECT * FROM models.users WHERE name = 'User_From_C';");
sql_read_query_result(ctx);
printf("\n--- STEP 3: Count all users again---\n");
sql_query(ctx, "SELECT count(*) FROM models.users;");
sql_read_query_result(ctx);
19:35:07 [SUCCESS] Database 'models' selected successfully. 19:35:07 [SUCCESS] Connected to MySQL server at 127.0.0.1:3306 19:35:07 [MSG] Sending query: SELECT * FROM models.users WHERE name = 'Ivo van Dijk'; 19:35:07 [ALERT] sql_send_packet tx->sequence_id 0 19:35:07 [SUCCESS] Send packet: len=56, sequence_id=0 HEX — SEND PAYLOAD (56 bytes)
30 0B 02 02 FF 85 04 05 68 65 6C 6C 6F
--- STEP 0: Count users --- 22:54:54 [MSG] Sending query: SELECT count(*) FROM models.users; 22:54:54 [ALERT] sql_send_packet tx->sequence_id 0 22:54:54 [SUCCESS] Send packet: len=35, sequence_id=0 22:54:54 [MSG] SQL result: count(*)89 Total Rows: 1 --- STEP 1: Insert a new user from C --- 22:54:54 [MSG] Sending query: INSERT INTO models.users (name, city, age, bio, created_at) VALUES ('User_From_C', 'CodeCity', 99, 'Born in C', NOW()); 22:54:54 [ALERT] sql_send_packet tx->sequence_id 0 22:54:54 [MSG] Last Insert ID: 90 --- STEP 2: Select that specific user --- 22:54:54 [MSG] Sending query: SELECT * FROM models.users WHERE name = 'User_From_C'; 22:54:54 [ALERT] sql_send_packet tx->sequence_id 0 22:54:54 [SUCCESS] Send packet: len=55, sequence_id=0 22:54:54 [MSG] SQL result: id | name | city | age | bio | created_at 87 | User_From_C | CodeCity | 99 | Born in C | 2025-12-01 18:59:28 88 | User_From_C | CodeCity | 99 | Born in C | 2025-12-01 19:03:26 89 | User_From_C | CodeCity | 99 | Born in C | 2025-12-01 19:03:30 90 | User_From_C | CodeCity | 99 | Born in C | 2025-12-01 21:54:54 -------------------------------------------------- Total Rows: 5 --- STEP 3: Count all users again --- 22:54:54 [MSG] Sending query: SELECT count(*) FROM models.users; 22:54:54 [MSG] SQL result: count(*)90