示例#1
0
    def _main_db_default(self):
        from apptools.preferences.preference_binding import bind_preference

        db = IsotopeAdapter()
        prefid = 'pychron.database'
        bind_preference(db, 'kind', '{}.kind'.format(prefid))
        if db.kind == 'mysql':
            bind_preference(db, 'host', '{}.host'.format(prefid))
            bind_preference(db, 'username', '{}.username'.format(prefid))
            bind_preference(db, 'password', '{}.password'.format(prefid))

        bind_preference(db, 'name', '{}.db_name'.format(prefid))
        return db
示例#2
0
def isotope_db_factory(path, remove=True):
    from pychron.database.adapters.isotope_adapter import IsotopeAdapter
    from pychron.database.orms.isotope.util import Base

    db = IsotopeAdapter()
    # db.verbose_retrieve_query = True
    db.trait_set(kind='sqlite', path=path)
    db.connect()

    if remove and os.path.isfile(db.path):
        os.remove(db.path)

    metadata = Base.metadata
    db.create_all(metadata)
    return db
示例#3
0
def isotope_db_factory(path, remove=True):
    from pychron.database.adapters.isotope_adapter import IsotopeAdapter
    from pychron.database.orms.isotope.util import Base

    db = IsotopeAdapter()
    # db.verbose_retrieve_query = True
    db.trait_set(kind='sqlite', path=path)
    db.connect()

    if remove and os.path.isfile(db.path):
        os.remove(db.path)

    metadata = Base.metadata
    db.create_all(metadata)
    return db
示例#4
0
                 resizable=True)
        return v


if __name__ == '__main__':

    class Detector(HasTraits):
        name = Str
        gain = Float

    class Spectrometer(HasTraits):
        detectors = List

    spec = Spectrometer()
    spec.detectors = [Detector(name='H1'), Detector(name='AX')]

    from pychron.database.adapters.isotope_adapter import IsotopeAdapter

    db = IsotopeAdapter(name='pychrondata_dev',
                        kind='mysql',
                        host='localhost',
                        username='******',
                        password='******')
    db.connect()
    # hist = [GainHistory(create_date=datetime.fromtimestamp(i),) for i in range(10)]
    gv = GainsModel(db=db, spectrometer=spec)
    gv.load_histories()
    gev = GainsEditView(model=gv)
    gev.configure_traits()
# ============= EOF =============================================
示例#5
0
                 title='View Detector Gain Histories',
                 resizable=True)
        return v


if __name__ == '__main__':
    class Detector(HasTraits):
        name = Str
        gain = Float

    class Spectrometer(HasTraits):
        detectors = List

    spec = Spectrometer()
    spec.detectors = [Detector(name='H1'), Detector(name='AX')]

    from pychron.database.adapters.isotope_adapter import IsotopeAdapter

    db = IsotopeAdapter(name='pychrondata_dev',
                        kind='mysql',
                        host='localhost',
                        username='******',
                        password='******')
    db.connect()
    # hist = [GainHistory(create_date=datetime.fromtimestamp(i),) for i in range(10)]
    gv = GainsModel(db=db, spectrometer=spec)
    gv.load_histories()
    gev = GainsEditView(model=gv)
    gev.configure_traits()
# ============= EOF =============================================