trac-dvbcronrecording-plugin / src / dvbcronrecording / db / db5.py

# http://trac-hacks.org/wiki/TracSqlAlchemyBridgeIntegration

from sqlalchemy import (
    # MetaData,
    # Boolean,
    Column,
    DateTime,
    # ForeignKey,
    Integer,
    String,
    # Unicode,
    )
#from sqlalchemy.orm import relationship, backref
#from sqlalchemy.orm.exc import NoResultFound

from sqlalchemy.ext.declarative import declarative_base
RecordingModel = declarative_base()

class RecordingList(RecordingModel):
    __tablename__ = "recording_list"
    id = Column('id', Integer, primary_key=True)
    channelname = Column('channelname', String)
    newtime = Column('newtime', String)
    endtime = Column('endtime', String)
    extratime = Column('extratime', String)
    onlydate = Column('onlydate', String)
    title = Column('title', String)
    status = Column('status', String)
    weekday = Column('weekday', Integer)
    priority = Column('priority', Integer)

class RecordingChannels(RecordingModel):
    __tablename__ = 'recording_channels'
    id = Column('id', Integer, primary_key=True)
    channelname = Column('channelname', String)
    adapter = Column('adapter', String)
    title = Column('title', String)

class RecordingChannelsConf(RecordingModel):
    __tablename__ = 'recording_channelsconf'
    adapter = Column('adapter', String, primary_key = True)
    title = Column('title', String, primary_key = True)
    frequency = Column('frequency', Integer)
    polarity = Column('polarity', String)
    source = Column('source', String)
    symbolrate = Column('symbolrate', Integer)
    vpid = Column('vpid', Integer)
    apid = Column('apid', Integer)
    tpid = Column('tpid', Integer)

class RecordingTuning(RecordingModel):
    __tablename__ = 'recording_tuning'
    id = Column("id", Integer, primary_key=True)
    adapter = Column('adapter', String)
    satellite = Column('satellite', String)
    transponder = Column('transponder', String)
    scansettings = Column('scansettings', String)
    scansourcefile = Column('scansourcefile', String)
    channelsconf = Column('channelsconf', String)

class RecordingChanges(RecordingModel):
    __tablename__ = 'recording_changes'
    id = Column("id", Integer, primary_key=True)
    tablename = Column("tablename", String)
    changed = Column("changed", String)
    username = Column("username", String)
    modified = Column("modified", DateTime)

class ProgramguideChannels(RecordingModel):
    __tablename__ = 'recording_programguide'
    id = Column("id", Integer, primary_key=True)
    programguide = Column("programguide", String)
    programchannel = Column("programchannel", String)
    channelname = Column("channelname", String)
    extratime = Column("extratime", String)
    extrapercent = Column("extrapercent", String)
    priority = Column("priority", Integer)

metadata = RecordingModel.metadata

from tsab import engine

def create_all(env, cursor):
    metadata.create_all(bind=engine(env))

def upgrade(env, cursor):
    import schemachange
    try:
        for sql in schemachange.migrate_AtoB(old_metadata(), metadata, env, excludeTables = None):
            print sql
    except Exception, e:
        import traceback
        traceback.print_exc(e)
        raise

def downgrade(env, cursor):
    import schemachange
    for sql in schemachange.migrate_BtoA(old_metadata(), metadata, env, excludeTables = None):
        print sql

def old_metadata():
    import db4
    return db4.metadata
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.