This wiki is in the process of being archived due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies. Edits are discouraged.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

{i} to use this script, you'll need the Library.fp7 and Library.tab sample files (I will post them asap) and to edit the DBPATH and IMPORTFILE variables accordingly.

   1 #!/usr/bin/pythonw
   2 
   3 from pprint import pprint
   4 from appscript import *
   5 from Carbon.File import FSSpec
   6 import codecs
   7 
   8 DBPATH = '/Users/SOMEUSER/Desktop/Library.fp7'
   9 DBNAME = 'Library'
  10 TBLNAME = 'Library'
  11 IMPORTFILE = '/Users/SOMEUSER/Desktop/library.tab'
  12 
  13 
  14 """ 
  15         Connecting to /FileMaker and opening database
  16 """
  17 
  18 fm = app(id='com.filemaker.pro7') # [1]
  19 
  20 if not fm.databases[DBNAME].exists():
  21         fm.open(FSSpec(DBPATH)) # [2]
  22 
  23 
  24 """
  25     Querying database schema
  26 """
  27 
  28 print "FileMaker has %d database(s) opened: " % fm.count(class_=k.database)
  29 print ", ".join(fm.databases.name.get()) # [3]
  30 
  31 db = fm.databases[DBNAME] # [3]
  32 
  33 print "\nDatabase '%s' has %d table(s): " % (DBNAME, db.count(class_='cTBL')) # [4]
  34 print ", ".join(db.tables.name.get())
  35 
  36 t1 = db.tables[TBLNAME]
  37 
  38 print "\nTable '%s' has %d field(s): " % (TBLNAME, t1.count(class_=k.field))
  39 print ", ".join(t1.fields.name.get())
  40 
  41 print "\nTable '%s' schema:\n(name, type, nulls OK, unique value, global value)" % TBLNAME
  42 pprint(zip(
  43         t1.fields.name.get(), 
  44         t1.fields.default_type.get(),
  45         t1.fields.nulls_OK.get(),
  46         t1.fields.unique_value.get(),
  47         t1.fields.globalValue.get()))
  48 
  49 
  50 """
  51         Creating new records
  52 """
  53 
  54 if t1.count(class_=