create TM from db, writer to xtm, load xtm to db, query