"""Test for foreign-key property operations""" from pytable.schemabuilder import * from pytable import dbschema, sqlgeneration, sqlquery, dbspecifier from pytable import dbproperty, specifierfromoptions import unittest, new, traceback testSpec = specifierfromoptions.specifierFromOptions() cats = database( "kitties", tables = [ table( "ownersforeignkey", ( field( "owner_id", "integer", 0, "Unique owner identifier", constraints = (notNull(),primary()), ), field( "owner_name", "text", 0, """Owner's first name""", constraints = (notNull(),), ), ), """Table for storing owner information""", friendlyNameField = "owner_name", defaultRecords = [ { "owner_id":1, "owner_name":"Tim" }, { "owner_id":2, "owner_name":"John" }, { "owner_id":3, "owner_name":"Jerry" }, { "owner_id":4, "owner_name":"Mike" }, ], ), table(
"""Test GUI browsing of dbase""" from pytable import dbspecifier, sqlquery, dbresultset, specifierfromoptions specifier = specifierfromoptions.specifierFromOptions() if __name__ == "__main__": print 'connecting to database', specifier driver, connection = specifier.connect() print 'quering database for schema', driver for table in driver.listTables(connection): schema = driver.tableStructure( connection, tableName = table ) break print 'got schema', schema.name print 'retrieving result-set' results = schema.query( """SELECT * FROM %(tableName)s;""", connection, tableName = table, ) print 'result-set', results for row in results: print 'row', repr(row) from wxoo.table import propertiedview from wxPython.wx import * class TestApplication (wxPySimpleApp): def OnInit(self): wxInitAllImageHandlers() frame =wxFrame (NULL, -1, "test", size = (600,300))