def create(args):
  """Creates or re-creates this database"""

  from bob.db.utils import session_try_nolock

  dbfile = args.files[0]

  if args.recreate:
    if args.verbose and os.path.exists(dbfile):
      print('unlinking %s...' % dbfile)
    if os.path.exists(dbfile): os.unlink(dbfile)

  if not os.path.exists(os.path.dirname(dbfile)):
    os.makedirs(os.path.dirname(dbfile))

  # the real work...
  create_tables(args)
  s = session_try_nolock(args.type, dbfile, echo=(args.verbose > 2))
  add_clients(s, args.verbose)
  add_files(s, args.imagedir, args.verbose)
  add_protocols(s, args.verbose)
  s.commit()
  s.close()
def create ( args ) : from bob . db . utils import session_try_nolock dbfile = args . files [ 0 ] if args . recreate : if args . verbose and os . path . exists ( dbfile ) : print ( 'unlinking %s...' % dbfile ) if os . path . exists ( dbfile ) : os . unlink ( dbfile ) if not os . path . exists ( os . path . dirname ( dbfile ) ) : os . makedirs ( os . path . dirname ( dbfile ) ) create_tables ( args ) s = session_try_nolock ( args . type , dbfile , echo = ( args . verbose > 2 ) ) add_clients ( s , args . verbose ) add_files ( s , args . imagedir , args . verbose ) add_protocols ( s , args . verbose ) s . commit ( ) s . close ( )
Creates or re-creates this database