Skip to content

Commit 7a98107

Browse files
committed
update README
1 parent 43768f5 commit 7a98107

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

README.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# QueryBuilder python module
22

3-
![PyPI](https://img.shields.io/pypi/v/simple-query-builder?color=yellow&style=flat-square)
4-
![PyPI - Downloads](https://img.shields.io/pypi/dm/simple-query-builder?color=darkgreen&style=flat-square)
53
[![Latest Version](https://img.shields.io/github/release/co0lc0der/simple-query-builder-python?color=orange&style=flat-square)](https://github.com/co0lc0der/simple-query-builder-python/release)
64
![GitHub repo size](https://img.shields.io/github/repo-size/co0lc0der/simple-query-builder-python?label=size&style=flat-square)
7-
![Python 3.7, 3.8, 3.9, 3.10](https://img.shields.io/pypi/pyversions/simple-query-builder?color=blueviolet&style=flat-square)
85
[![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)
6+
![Python 3.7, 3.8, 3.9, 3.10](https://img.shields.io/pypi/pyversions/simple-query-builder?color=blueviolet&style=flat-square)
7+
![PyPI](https://img.shields.io/pypi/v/simple-query-builder?color=yellow&style=flat-square)
8+
![PyPI - Downloads](https://img.shields.io/pypi/dm/simple-query-builder?color=darkgreen&style=flat-square)
99

1010
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

@@ -46,6 +46,7 @@ pip install https://github.com/co0lc0der/simple-query-builder-python/archive/mai
4646
- `column(col_index)` executes SQL query and returns the needed column of result, `col_index` is `0` by default
4747
- `pluck(key_index, col_index)` executes SQL query and returns a list of tuples (the key (usually ID) and the needed column of result), `key_index` is `0` and `col_index` is `1` by default
4848
- `go()` this method is for non `SELECT` queries. it executes SQL query and returns nothing (but returns the last inserted row ID for `INSERT` method)
49+
- `exists()` returns `True` if SQL query has a row
4950
- `count()` prepares a query with SQL `COUNT(*)` function and executes it
5051
- `query(sql, params, fetch_type, col_index)` executes prepared `sql` with `params`, it can be used for custom queries
5152
- 'SQL' methods are presented in [Usage section](#usage-examples)
@@ -85,20 +86,43 @@ SELECT * FROM `users` WHERE (`id` > 1) AND (`group_id` = 2);
8586
- Select a row with a `LIKE` and `NOT LIKE` condition
8687
```python
8788
results = qb.select('users').like(['name', '%John%']).all()
89+
# or since 0.3.5
90+
results = qb.select('users').like('name', '%John%').all()
8891
# or
8992
results = qb.select('users').where([['name', 'LIKE', '%John%']]).all()
9093
```
9194
```sql
9295
SELECT * FROM `users` WHERE (`name` LIKE '%John%');
9396
```
9497
```python
95-
results = qb.select('users').notLike(['name', '%John%']).all()
98+
results = qb.select('users').not_like(['name', '%John%']).all()
99+
# or since 0.3.5
100+
results = qb.select('users').not_like('name', '%John%').all()
96101
# or
97102
results = qb.select('users').where([['name', 'NOT LIKE', '%John%']]).all()
98103
```
99104
```sql
100105
SELECT * FROM `users` WHERE (`name` NOT LIKE '%John%');
101106
```
107+
- Select a row with a `IS NULL` and `IS NOT NULL` condition (since 0.3.5)
108+
```python
109+
results = qb.select('users').is_null('phone').all()
110+
# or
111+
results = qb.select('users').where([['phone', 'is null']]).all()
112+
```
113+
```sql
114+
SELECT * FROM `users` WHERE (`phone` IS NULL);
115+
```
116+
```python
117+
results = qb.select('customers').is_not_null('address').all()
118+
# or
119+
results = qb.select('customers').not_null('address').all()
120+
# or
121+
results = qb.select('customers').where([['address', 'is not null']]).all()
122+
```
123+
```sql
124+
SELECT * FROM `customers` WHERE (`address` IS NOT NULL);
125+
```
102126
- Select rows with `OFFSET` and `LIMIT`
103127
```python
104128
results = qb.select('posts')\
@@ -331,13 +355,17 @@ qb.delete('comments')\
331355
DELETE FROM `comments` WHERE `user_id` = 10;
332356
```
333357
- Truncate a table
358+
359+
This method will be moved to another class
334360
```python
335361
qb.truncate('users').go()
336362
```
337363
```sql
338364
TRUNCATE TABLE `users`;
339365
```
340366
- Drop a table
367+
368+
This method will be moved to another class
341369
```python
342370
qb.drop('temporary').go()
343371
```

0 commit comments

Comments
 (0)