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