'Save attributes about this DAG to the DB. Note that this method
can be called for both DAGs and SubDAGs. A SubDag is actually a
SubDagOperator.
:param dag: the DAG object to save to the DB
:type dag: DAG
:param sync_time: The time that the DAG should be marked as sync\'ed
:type sync_time: datetime
:return: None'

@staticmethod
@provide_session
def sync_to_db(dag, owner, sync_time, session=None):

    orm_dag = session.query(DagModel).filter((DagModel.dag_id == dag.dag_id)).first()
    if (not orm_dag):
        orm_dag = DagModel(dag_id=dag.dag_id)
        logging.info(u'Creating    ORM    DAG    for    %s', dag.dag_id)
    orm_dag.fileloc = dag.fileloc
    orm_dag.is_subdag = dag.is_subdag
    orm_dag.owners = owner
    orm_dag.is_active = True
    orm_dag.last_scheduler_run = sync_time
    session.merge(orm_dag)
    session.commit()
    for subdag in dag.subdags:
        DAG.sync_to_db(subdag, owner, sync_time, session=session)
