13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Working with databaseshttp://www.zetcode.com/wxpython/databases/format. <strong>The</strong>se SQL commands will recreate the table into the originalstate. We copy and paste these SQL commnads into a neighbours.sqltext file.In the next steps we drop a table and recreate it from our file.sqlite> drop table neighbours;sqlite> .tablessqlite> .read ../neighbours.sqlsqlite> .tablesneighbourssqlite> select * from neighbours;name age remark---------- ---------- ----------sandy 7 stubbornjane 18 beautifulmark 28 lazysteven 34 friendlyalice 17 slicktom 25 cleverjack 89 wiselucy 18 cuteWe drop the neighbours table with the drop table SQL command.<strong>The</strong> command .tables shows no table. <strong>The</strong>n we type sqlite .readcommand to execute all SQL commands in the specified file. Finally,we verify our data.SQLite python APIpysqlite is a python interface to the SQLite library. From python2.5xseries, it is included in the python language. <strong>The</strong> pysqlite module isincluded under the package name sqlite3.import sqlite3 as liteSimple stepscreate connection objectcreate cursor objectexecute queryfetch data (optional)close cursor and connection objectsTo create a connection, we call the connect() module method.import sqlite3 as litecon = lite.connect('databasename')con = lite.connect(':memory:')6 de 12 27/04/2008 1:06

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!