Skip to content

Commit a3e08d2

Browse files
committed
update README
1 parent 348c46e commit a3e08d2

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
![Python 3.7, 3.8, 3.9, 3.10](https://img.shields.io/pypi/pyversions/simple-query-builder?color=blueviolet&style=flat-square)
88
[![GitHub license](https://img.shields.io/github/license/co0lc0der/simple-query-builder-python?style=flat-square)](https://github.com/co0lc0der/simple-query-builder-python/blob/main/LICENSE.md)
99

10-
This is a small easy-to-use component for working with a database. It provides some public methods to compose SQL queries and manipulate data. Each SQL query is prepared and safe. QueryBuilder fetches data to _list_ by default. At present time the component supports SQLite (file or memory).
10+
This is a small easy-to-use module for working with a database. It provides some public methods to compose SQL queries and manipulate data. Each SQL query is prepared and safe. QueryBuilder fetches data to _list_ by default. At present time the component supports SQLite (file or memory).
1111

1212
## Contributing
1313

@@ -72,12 +72,10 @@ SELECT * FROM `users` WHERE `id` = 10;
7272
```
7373
- Select rows with two conditions
7474
```python
75-
results = qb.select('users')\
76-
.where([['id', '>', 1], 'and', ['group_id', '=', 2]])\
77-
.all()
75+
results = qb.select('users').where([['id', '>', 1], 'and', ['group_id', '=', 2]]).all()
7876
```
7977
```sql
80-
SELECT * FROM `users` WHERE (`id` > 1) AND (`group_id` = 2)
78+
SELECT * FROM `users` WHERE (`id` > 1) AND (`group_id` = 2);
8179
```
8280
- Select a row with a `LIKE` and `NOT LIKE` condition
8381
```python
@@ -86,15 +84,15 @@ results = qb.select('users').like(['name', '%John%']).all()
8684
results = qb.select('users').where([['name', 'LIKE', '%John%']]).all()
8785
```
8886
```sql
89-
SELECT * FROM `users` WHERE (`name` LIKE '%John%')
87+
SELECT * FROM `users` WHERE (`name` LIKE '%John%');
9088
```
9189
```python
9290
results = qb.select('users').notLike(['name', '%John%']).all()
9391
# or
9492
results = qb.select('users').where([['name', 'NOT LIKE', '%John%']]).all()
9593
```
9694
```sql
97-
SELECT * FROM `users` WHERE (`name` NOT LIKE '%John%')
95+
SELECT * FROM `users` WHERE (`name` NOT LIKE '%John%');
9896
```
9997
- Select rows with `OFFSET` and `LIMIT`
10098
```python
@@ -150,7 +148,7 @@ groups = qb.select('orders', {'month_num': 'MONTH(`created_at`)', 'total': 'SUM(
150148
```sql
151149
SELECT MONTH(`created_at`) AS `month_num`, SUM(`total`) AS `total`
152150
FROM `orders` WHERE (YEAR(`created_at`) = 2020)
153-
GROUP BY `month_num` HAVING (`total` > 20000)
151+
GROUP BY `month_num` HAVING (`total` > 20000);
154152
```
155153
4. `JOIN`. Supports `INNER`, `LEFT OUTER`, `RIGHT OUTER`, `FULL OUTER` and `CROSS` joins (`INNER` is by default)
156154
```python
@@ -193,7 +191,7 @@ FROM `cabs_printers` AS `cp`
193191
INNER JOIN `cabs` AS `cb` ON `cp`.`cab_id` = `cb`.`id`
194192
INNER JOIN `printer_models` AS `p` ON `cp`.`printer_id` = `p`.`id`
195193
INNER JOIN `cartridge_types` AS `c` ON p.cartridge_id=c.id
196-
WHERE (`cp`.`cab_id` IN (11,12,13)) OR (`cp`.`cab_id` = 5) AND (`p`.`id` > `c`.`id`)
194+
WHERE (`cp`.`cab_id` IN (11,12,13)) OR (`cp`.`cab_id` = 5) AND (`p`.`id` > `c`.`id`);
197195
```
198196
- Insert a row
199197
```python
@@ -203,7 +201,7 @@ new_id = qb.insert('groups', {
203201
}).go()
204202
```
205203
```sql
206-
INSERT INTO `groups` (`name`, `permissions`) VALUES ('Moderator', 'moderator')
204+
INSERT INTO `groups` (`name`, `permissions`) VALUES ('Moderator', 'moderator');
207205
```
208206
- Insert many rows
209207
```python
@@ -219,7 +217,7 @@ INSERT INTO `groups` (`name`, `role`)
219217
VALUES ('Moderator', 'moderator'),
220218
('Moderator2', 'moderator'),
221219
('User', 'user'),
222-
('User2', 'user')
220+
('User2', 'user');
223221
```
224222
- Update a row
225223
```python
@@ -243,7 +241,7 @@ qb.update('posts', {'status': 'published'})\
243241
```
244242
```sql
245243
UPDATE `posts` SET `status` = 'published'
246-
WHERE (YEAR(`updated_at`) > 2020)
244+
WHERE (YEAR(`updated_at`) > 2020);
247245
```
248246
- Delete a row
249247
```python

0 commit comments

Comments
 (0)