Source code for airflow.models.chart

# -*- coding: utf-8 -*-
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

from sqlalchemy import Column, String, Integer, Boolean, ForeignKey, Text
from sqlalchemy.orm import relationship

from airflow.models.base import Base, ID_LEN
from airflow.utils.sqlalchemy import UtcDateTime
from airflow.utils import timezone


[docs]class Chart(Base):
[docs] __tablename__ = "chart"
[docs] id = Column(Integer, primary_key=True)
[docs] label = Column(String(200))
[docs] conn_id = Column(String(ID_LEN), nullable=False)
[docs] user_id = Column(Integer(), ForeignKey('users.id'), nullable=True)
[docs] chart_type = Column(String(100), default="line")
[docs] sql_layout = Column(String(50), default="series")
[docs] sql = Column(Text, default="SELECT series, x, y FROM table")
[docs] y_log_scale = Column(Boolean)
[docs] show_datatable = Column(Boolean)
[docs] show_sql = Column(Boolean, default=True)
[docs] height = Column(Integer, default=600)
[docs] default_params = Column(String(5000), default="{}")
[docs] owner = relationship( "User", cascade=False, cascade_backrefs=False, backref='charts')
[docs] x_is_date = Column(Boolean, default=True)
[docs] iteration_no = Column(Integer, default=0)
[docs] last_modified = Column(UtcDateTime, default=timezone.utcnow)
[docs] def __repr__(self): return self.label