@provide_session<EOL><INDENT>def sync_to_db(self, owner=None, sync_time=None, session=None):<DEDENT>
if owner is None:<EOL><INDENT>owner = self.owner<EOL><DEDENT>if sync_time is None:<EOL><INDENT>sync_time = timezone.utcnow()<EOL><DEDENT>orm_dag = session.query(<EOL>DagModel).filter(DagModel.dag_id == self.dag_id).first()<EOL>if not orm_dag:<EOL><INDENT>orm_dag = DagModel(dag_id=self.dag_id)<EOL>self.log.info("<STR_LIT>", self.dag_id)<EOL><DEDENT>orm_dag.fileloc = self.fileloc<EOL>orm_dag.is_subdag = self.is_subdag<EOL>orm_dag.owners = owner<EOL>orm_dag.is_active = True<EOL>orm_dag.last_scheduler_run = sync_time<EOL>orm_dag.default_view = self._default_view<EOL>orm_dag.description = self.description<EOL>orm_dag.schedule_interval = self.schedule_interval<EOL>session.merge(orm_dag)<EOL>session.commit()<EOL>for subdag in self.subdags:<EOL><INDENT>subdag.sync_to_db(owner=owner, sync_time=sync_time, session=session)<EOL><DEDENT>
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: airflow.models.DAG
:param sync_time: The time that the DAG should be marked as sync'ed
:type sync_time: datetime
:return: None