<commit_before>"""
SQLAlchemy models for site hierarchy/relationships generated using sqlacodegen:
$ pip install sqlacodegen
$ sqlacodegen oracle://<user>:<pwd>@<database> --outfile /tmp/models.py --schema atlas_panda
Then take the tables that are relevant for your exercise.
"""
# coding: utf-8
from sqlalchemy import Column, DateTime, ForeignKey, ForeignKeyConstraint, Index, Numeric, String, Table, Text, Unicode, text
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base


Base = declarative_base()
metadata = Base.metadata


class Site(Base):
    __tablename__ = 'site'
    __table_args__ = {u'schema': 'atlas_panda'}

    site_name = Column(String(52), primary_key=True)
    role = Column(String(256))
    tier_level = Column(Numeric(1, 0, asdecimal=False))
    state = Column(String(52))

class PandaSite(Base):
    __tablename__ = 'panda_site'
    __table_args__ = {u'schema': 'atlas_panda'}

    panda_site_name = Column(String(52), primary_key=True)
    site_name = Column(ForeignKey(u'atlas_panda.site.site_name', ondelete='CASCADE'))
    storage_site_name = Column(ForeignKey(u'atlas_panda.site.site_name'))
    default_ddm_endpoint = Column(ForeignKey(u'atlas_panda.ddm_endpoint.ddm_endpoint_name'))
    is_local = Column(String(1))

    site = relationship('Site', foreign_keys=site_name)
    storage_site = relationship('Site', foreign_keys=storage_site_name)
    default_endpoint = relationship('DdmEndpoint', foreign_keys=default_ddm_endpoint)

class DdmEndpoint(Base):
    __tablename__ = 'ddm_endpoint'
    __table_args__ = {u'schema': 'atlas_panda'}

    ddm_endpoint_name = Column(String(52), primary_key=True)
    site_name = Column(ForeignKey(u'atlas_panda.site.site_name', ondelete='CASCADE'))
    ddm_spacetoken_name = Column(String(52))
    space_total = Column(Numeric(10, 0, asdecimal=False))
    space_free = Column(Numeric(10, 0, asdecimal=False))
    space_used = Column(Numeric(10, 0, asdecimal=False))
    space_expired = Column(Numeric(10, 0, asdecimal=False))
    space_timestamp = Column(DateTime)
    is_tape = Column(String(1))
    type = Column(String(20))
    blacklisted = Column(String(1))

    site = relationship('Site')


class SiteStats(Base):
    __tablename__ = 'site_stats'
    __table_args__ = {u'schema': 'atlas_panda'}

    site_name = Column(ForeignKey(u'atlas_panda.site.site_name'), primary_key=True)
    ts = Column(DateTime, primary_key=True)
    key = Column(String(52), primary_key=True)
    value = Column(Numeric(10, 0, asdecimal=False))

    site = relationship('Site')


class PandaDdmRelation(Base):
    __tablename__ = 'panda_ddm_relation'
    __table_args__ = {u'schema': 'atlas_panda'}

    panda_site_name = Column(String(52), ForeignKey(u'atlas_panda.panda_site.panda_site_name', ondelete='CASCADE'), primary_key=True, nullable=False)
    ddm_endpoint_name = Column(String(52), ForeignKey(u'atlas_panda.ddm_endpoint.ddm_endpoint_name',  ondelete='CASCADE'), primary_key=True, nullable=False)
    roles = Column(String(60))
    order_read = Column(Numeric(3, 0, asdecimal=False))
    order_write = Column(Numeric(3, 0, asdecimal=False))
    is_local = Column(String(1))
    default_read = Column(String(1))
    default_write = Column(String(1))
    scope = Column(String(60))


class Schedconfig(Base):
    __tablename__ = 'schedconfig'
    __table_args__ = {u'schema': 'atlas_pandameta'}
<commit_msg>prodanaly: fixed configurator SQLAlchemy models.py for panda ddm relation table<commit_after>"""
SQLAlchemy models for site hierarchy/relationships generated using sqlacodegen:
$ pip install sqlacodegen
$ sqlacodegen oracle://<user>:<pwd>@<database> --outfile /tmp/models.py --schema atlas_panda
Then take the tables that are relevant for your exercise.
"""
# coding: utf-8
from sqlalchemy import Column, DateTime, ForeignKey, ForeignKeyConstraint, Index, Numeric, String, Table, Text, Unicode, text
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base


Base = declarative_base()
metadata = Base.metadata


class Site(Base):
    __tablename__ = 'site'
    __table_args__ = {u'schema': 'atlas_panda'}

    site_name = Column(String(52), primary_key=True)
    role = Column(String(256))
    tier_level = Column(Numeric(1, 0, asdecimal=False))
    state = Column(String(52))

class PandaSite(Base):
    __tablename__ = 'panda_site'
    __table_args__ = {u'schema': 'atlas_panda'}

    panda_site_name = Column(String(52), primary_key=True)
    site_name = Column(ForeignKey(u'atlas_panda.site.site_name', ondelete='CASCADE'))
    storage_site_name = Column(ForeignKey(u'atlas_panda.site.site_name'))
    default_ddm_endpoint = Column(ForeignKey(u'atlas_panda.ddm_endpoint.ddm_endpoint_name'))
    is_local = Column(String(1))

    site = relationship('Site', foreign_keys=site_name)
    storage_site = relationship('Site', foreign_keys=storage_site_name)
    default_endpoint = relationship('DdmEndpoint', foreign_keys=default_ddm_endpoint)

class DdmEndpoint(Base):
    __tablename__ = 'ddm_endpoint'
    __table_args__ = {u'schema': 'atlas_panda'}

    ddm_endpoint_name = Column(String(52), primary_key=True)
    site_name = Column(ForeignKey(u'atlas_panda.site.site_name', ondelete='CASCADE'))
    ddm_spacetoken_name = Column(String(52))
    space_total = Column(Numeric(10, 0, asdecimal=False))
    space_free = Column(Numeric(10, 0, asdecimal=False))
    space_used = Column(Numeric(10, 0, asdecimal=False))
    space_expired = Column(Numeric(10, 0, asdecimal=False))
    space_timestamp = Column(DateTime)
    is_tape = Column(String(1))
    type = Column(String(20))
    blacklisted = Column(String(1))

    site = relationship('Site')


class SiteStats(Base):
    __tablename__ = 'site_stats'
    __table_args__ = {u'schema': 'atlas_panda'}

    site_name = Column(ForeignKey(u'atlas_panda.site.site_name'), primary_key=True)
    ts = Column(DateTime, primary_key=True)
    key = Column(String(52), primary_key=True)
    value = Column(Numeric(10, 0, asdecimal=False))

    site = relationship('Site')


class PandaDdmRelation(Base):
    __tablename__ = 'panda_ddm_relation'
    __table_args__ = {u'schema': 'atlas_panda'}

    panda_site_name = Column(String(52), ForeignKey(u'atlas_panda.panda_site.panda_site_name', ondelete='CASCADE'),
                             primary_key=True, nullable=False)
    ddm_endpoint_name = Column(String(52), ForeignKey(u'atlas_panda.ddm_endpoint.ddm_endpoint_name',  ondelete='CASCADE'),
                               primary_key=True, nullable=False)
    scope = Column(String(60), primary_key=True, nullable=False)
    roles = Column(String(60))
    order_read = Column(Numeric(3, 0, asdecimal=False))
    order_write = Column(Numeric(3, 0, asdecimal=False))
    is_local = Column(String(1))
    default_read = Column(String(1))
    default_write = Column(String(1))


class Schedconfig(Base):
    __tablename__ = 'schedconfig'
    __table_args__ = {u'schema': 'atlas_pandameta'}

{'fraction_non_alphanumeric': 0.12199312714776632, 'fraction_numerical': 0.015177548682703322, 'mean_word_length': 5.321266968325792, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '954086', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2388, 'n_words': 429}