Changes between Version 19 and Version 20 of TutorialDivingIn

Show
Ignore:
Timestamp:
10/15/09 16:27:28 (4 years ago)
Author:
guest (IP: 82.227.168.179)
Comment:

added some update/delete docs

Legend:

Unmodified
Added
Removed
Modified
  • TutorialDivingIn

    v19 v20  
    121121}}} 
    122122 
    123 Not many, but exactly what we expected. Close the interpreter now and delete the database file (`movies.sqlite`)^4^, we will recreate and populate it in the next step. 
    124  
    125 So far you've seen how to declare simple entities, create objects, store them 
     123Not many, but exactly what we expected. This can be used to access your objects: 
     124 
     125{{{ 
     126#!python 
     127>>> movie = Movie.query.all()[0] 
     128>>> movie.year = 1983 
     129>>> movie = Movie.query.all() 
     130[<Movie "Blade Runner" (1983)>] 
     131}}} 
     132 
     133Or even delete it: 
     134 
     135{{{ 
     136#!python 
     137>>> Movie.delete(movie) 
     138}}} 
     139 
     140There should not be any movie left in the database now ! 
     141 
     142{{{ 
     143#!python 
     144>>> Movie.query.all() 
     145[] 
     146}}} 
     147 
     148Close the interpreter now and delete the database file (`movies.sqlite`)^4^, we will recreate and populate it in the next step. 
     149 
     150So far you've seen how to declare simple entities, create objects, store them, modify them, or even delete them, 
    126151to the database and retrieve them again. Not too much magic, but a lot more  
    127152pleasant to the eye compared to calling lowlevel SQL-statements.