Added content

This commit is contained in:
Gerben Aaltink 2024-11-22 14:01:51 +01:00
parent eaf2a538df
commit 5197e3f8f4

View File

@ -24,23 +24,23 @@ The python library is low quality. I made it just for fun and test. This is not
## C API examples:
### Connecting
```
```c
int db = sormc("db.sqlite3");
```
### Create table
This one should return True if executed.
```
```c
sormq(db, "CREATE TABLE IF NOT EXISTS pony (id INTEGER PRIMARY KEY AUTOINCREMENT,name,age);",NULL);
```
### Inserting
```
```c
sorm_pk iid = sormq(db, "INSERT INTO pony (id, name, age) VALUES (NULL, %s, %d);",
"Retoorded retoor",
42
);
```
Using `?` is also possible for arguments like this (comfy for Python usage):
```
```c
sorm_pk iid = sormq(db, "INSERT INTO pony (id, name, age) VALUES (NULL, ?s, ?d);",
"Retoorded retoor",
42
@ -48,18 +48,18 @@ sorm_pk iid = sormq(db, "INSERT INTO pony (id, name, age) VALUES (NULL, ?s, ?d);
```
### Selecting
IN query
```
```c
sorm_str csv = sormq(db, "SELECT * FROM pony WHERE id in (?d,?d,?d)",1,2,3);
free(sorm_str);
```
LIKE query
```
```c
sorm_str csv2 = sormq(db, "SELECT * FROM pony WHERE id > %d and age = %d AND name LIKE ?s", 1, 34, "%toor%"));
free(sorm_str);
```
Yes, you did see that right, you can use the default native free!
### Disconnecting
```
```c
sormd(db);
```