123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # @File : db.py.py
- # @Author: becivells
- #@Contact : becivells@gmail.com
- # @Date : 2018/4/21
- #@Software : PyCharm
- # @Desc :
- import os
- from sqlalchemy import Column,VARCHAR
- from sqlalchemy.ext.declarative import declarative_base
- from config import engine,session_class
- from config import repo as configrepo
- Base = declarative_base()
- class Data(Base):
- __tablename__ = 'data'
- id = Column(VARCHAR(40),primary_key=True,nullable=False)
- name = Column(VARCHAR(30))
- path = Column(VARCHAR(100))
- ip = Column(VARCHAR(200))
- cmd = Column(VARCHAR(100))
- user = Column(VARCHAR(30))
- interval = Column(VARCHAR(30))
- def get_dbconf():
- session = session_class()
- datas = session.query(Data).all()
- session.close()
- repo = {}
- for data in datas:
- if data:
- if data.ip:
- ip = data.ip.split(',')
- else:
- ip = ''
- repo.update({data.id:{
- "name":data.name,
- "path":data.path,
- "ip":ip,
- "cmd":'git pull origin master',
- "user":data.user,
- 'interval':3
- }})
- return repo
- # def init():
- # Base.metadata.create_all(engine)
- # print (get_dbconf())
|