Skip to content

Commit 70a27c1

Browse files
Add explanation how to run queries manually
1 parent 7c069dc commit 70a27c1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,34 @@ $ python manage.py runserver
4040

4141
More information? Follow explanatory videos below.
4242

43+
## How to execute queries manually?
44+
45+
Inside on your virtualenv:
46+
```
47+
$ python manage.py shell
48+
```
49+
50+
Import db and model:
51+
```
52+
from tvseries.ext import db
53+
from tvseries.core.models import TVSerie
54+
```
55+
56+
Bind your session with your application:
57+
```
58+
db.app = app
59+
```
60+
61+
Quering example:
62+
```
63+
db.session.query(TVSerie).all()
64+
```
65+
66+
If operation is "create", "update" or "delete" dont forget to run commit operation to confirm operation:
67+
```
68+
db.session.commit()
69+
```
70+
4371
## 1.0 - Flask and the most basic application of the world!
4472

4573
- See release code: https://github.com/rafaelhenrique/flask_tutorial/tree/1.0

0 commit comments

Comments
 (0)