Skip to content

Commit 1811d58

Browse files
committed
update README
1 parent 6eb5cdb commit 1811d58

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

README.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ pip install https://github.com/co0lc0der/simple-query-builder-python/archive/mai
3232
## How to use
3333
### Main public methods
3434
- `get_sql()` returns SQL query string which will be executed
35-
- `get_params()` returns an array of parameters for a query
35+
- `get_params()` returns a tuple of parameters for a query
3636
- `get_result()` returns query's result
3737
- `get_count()` returns result's rows count
3838
- `get_error()` returns `True` if an error is had
3939
- `get_error_message()` returns an error message if an error is had
4040
- `set_error(message)` sets `_error` to `True` and `_error_essage`
4141
- `get_first()` returns the first item of results
4242
- `get_last()` returns the last item of results
43-
- `reset()` resets state to default values (except PDO property)
43+
- `reset()` resets state to default values
4444
- `all()` executes SQL query and returns all rows of result (`fetchall()`)
4545
- `one()` executes SQL query and returns the first row of result (`fetchone()`)
4646
- `column(col_index)` executes SQL query and returns the needed column of result, `col_index` is `0` by default
@@ -55,7 +55,14 @@ pip install https://github.com/co0lc0der/simple-query-builder-python/archive/mai
5555
```python
5656
from simple_query_builder import *
5757

58-
qb = QueryBuilder(DataBase(), 'my_db.db')
58+
# if you want to get results as a list of dictionaries (by default since 0.3.5)
59+
qb = QueryBuilder(DataBase(), 'my_db.db') # result_dict=True, print_errors=False
60+
61+
# or if you want to get results as a list of tuples (since 0.3.5)
62+
qb = QueryBuilder(DataBase(), 'my_db.db', result_dict=False)
63+
64+
# for printing errors into terminal (since 0.3.5)
65+
qb = QueryBuilder(DataBase(), 'my_db.db', print_errors=True)
5966
```
6067
### Usage examples
6168
- Select all rows from a table
@@ -86,20 +93,20 @@ SELECT * FROM `users` WHERE (`id` > 1) AND (`group_id` = 2);
8693
- Select a row with a `LIKE` and `NOT LIKE` condition
8794
```python
8895
results = qb.select('users').like(['name', '%John%']).all()
89-
# or since 0.3.5
90-
results = qb.select('users').like('name', '%John%').all()
9196
# or
9297
results = qb.select('users').where([['name', 'LIKE', '%John%']]).all()
98+
# or since 0.3.5
99+
results = qb.select('users').like('name', '%John%').all()
93100
```
94101
```sql
95102
SELECT * FROM `users` WHERE (`name` LIKE '%John%');
96103
```
97104
```python
98105
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()
101106
# or
102107
results = qb.select('users').where([['name', 'NOT LIKE', '%John%']]).all()
108+
# or since 0.3.5
109+
results = qb.select('users').not_like('name', '%John%').all()
103110
```
104111
```sql
105112
SELECT * FROM `users` WHERE (`name` NOT LIKE '%John%');

0 commit comments

Comments
 (0)