Update 'README.md'
This commit is contained in:
parent
815bbbc2da
commit
acde2f37f3
12
README.md
12
README.md
@ -23,21 +23,21 @@ pip install git+https://git.nxhs.cloud/ge/quicker
|
||||
```python
|
||||
with Connection(**config) as db:
|
||||
db.exec("sql query here...")
|
||||
db.query(sql query here...") # query is alias for exec()
|
||||
db.query("sql query here...") # query is alias for exec()
|
||||
|
||||
# Query is callable and you can also do this:
|
||||
with Connection(**config) as query:
|
||||
query("sql query here...")
|
||||
```
|
||||
|
||||
`Query` cannot be called itself, you must use `Connection` to correctly initialise `Query` object.
|
||||
|
||||
Methods and properties:
|
||||
`Query` cannot be called itself, you must use `Connection` to correctly initialise `Query` object. Available methods and properties:
|
||||
|
||||
- `query()`, `exec()`. Execute SQL. There is You can use here this syntax: `query('SELECT * FROM users WHERE id = %s', (15,))`.
|
||||
- `commit()`. Write changes into database.
|
||||
- `cursor`. Call [MySQLdb Cursor object](https://mysqlclient.readthedocs.io/user_guide.html#cursor-objects) methods directly.
|
||||
|
||||
Full example:
|
||||
|
||||
```python
|
||||
import json
|
||||
|
||||
@ -76,6 +76,8 @@ print(json.dumps(users, indent=4))
|
||||
]
|
||||
```
|
||||
|
||||
Changing database:
|
||||
|
||||
```python
|
||||
from quicker import Connection
|
||||
|
||||
@ -83,4 +85,4 @@ with Connection(provider='mysql', read_default_file='~/.my.cnf') as db:
|
||||
db.query("INSERT INTO users VALUE (3, 'user2', 'user2@example.org')")
|
||||
```
|
||||
|
||||
Quicker by default make commit after closing context. Set option `commit=False` to disable automatic commit.
|
||||
Quicker by default make commit after closing context. Set option `commit=False` to disable automatic commit.
|
Loading…
Reference in New Issue
Block a user