Page 350 -
P. 350

database connection process


           Exploit Python’s database API


           The Python Database API provides a standard mechanism for
           programming a wide variery of database management systems, including
           SQLite. The process you follow in your code is the same regardless of which
           back-end database you’re using.


                                                 Connect
                                                 Establish a connection to your
                                                 chosen database back end.





                                                 Create
                                                 Create a cursor to communicate through the
                                                 connecton to your data.





                                                 Interact
                                                 Using the cursor, manipulate your
                                                 data using SQL.







                      Commit                                               Rollback
                      Tell your connection to apply                        Tell your connection to abort your
                      all of your SQL manipulations               Poof!    SQL manipulations, returning your
                      to your data and make them                           data to the state it was in before your
                      permanent.                                           interactions started.







                                                  Close
                                                  Destroy the connection to the
                                                  database back end.              When you close your
                                                                                  connection, your cursor
                                                                                  is destroyed, too.



           314    Chapter 9
   345   346   347   348   349   350   351   352   353   354   355