# Time_Data **Repository Path**: cgai/time_-data ## Basic Information - **Project Name**: Time_Data - **Description**: 数据中心读取 - **Primary Language**: Python - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-12-15 - **Last Updated**: 2022-03-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Time_Data #### 介绍 TD包为Time_Data简称,是针对时光坐标内部数据中心进行数据库以及数据处理的接口包 功能包括但不限于: 1.数据库的创建 2.cgtw数据处理 3.排期软件数据处理 4.数据分析与统计 ###### 软件架构说明 TD包: timeaxis data数据处理包 里面含各数据库的对应脚本,其中: CONFIG.py : 数据库配置 CreateDB.py : 数据库创建脚本 CGTWDB6.py :操作cgtw6数据库脚本 ScheduleDB.py :操作排期软件数据库脚本 ScheduleDB5.py :操作原排期软件数据库脚本 DBhandler.py: 综合数据处理脚本,拥有方便调用所用的所有数据库信息的函数 sync5to6.py: 将原排期软件数据库迁移到新排期软件数据库中 #### 安装教程 整个TD目录就是一个python包,将整个TD作为包导入即可,示例 ```python from TD.DBhandler import Handler from TD.CGTWDB6 import CGTW6Handler from TD.CreateDB import DBManager from TD.sync5to6 import Sync5to6 from TD.ScheduleDB import SchedulerHandler from TD.ScheduleDB5 import Scheduler5Handler ``` #### 使用说明 ##### cgtw与排期软件数据同步 1. 首先在CONFIG.py里配置数据库连接信息,示例: ```python #cgtw: 连接cgtw数据库 CGTW = {'database':'cgtw','host':'192.168.53.26','user':'timeaxis', 'password':'timeaxis','port':5432,'api_port':8383} #cgtw_login : 用来登陆cgtw获取token CGTW_LOGIN = {'account':'TD_machine','password':'timeaxis', 'controller':'c_token','method':'login','client_type':'py'} #schedule :连接排期数据库 # schedule = {'database':'forclear','host':'192.168.53.20','user':'postgres','password':'timeaxis','port':5432} SCHEDULER = {'database':'testforcgtw6','host':'192.168.1.222','user':'postgres','password':'timeaxis','port':5432} #ad : 广告栏数据库 AD = {'database':'ad','host':'192.168.1.222','user':'timeaxis','password':'timeaxis','port':5432} #TG:taskprogress 任务进度统计 TG = {'database':'taskprogress','host':'192.168.1.222','user':'timeaxis','password':'timeaxis','port':5432} ``` 2. 创建新数据库以及数据表,示例: ```python from TD.CreateDB import DBManager manager = DBManager('forclear') # forclear为数据库名称,需与CONFIG.py中一致 manager._init_scheduler_tables() ``` 3. 同步cgtw数据到排期软件数据库,示例: ```python from TD.DBhandler import Handler handler = Handler() handler.sync_all() ``` ##### 数据分析与统计 ... ##### 支持任务更新 接受cgtw中entity里的任务id信息,通过DBhandler.py可进行更新, 也就是说支持cgtw手动任务更新 ```python #传入schema名称与entity表中的任务id列表,即可进行更新 handler.sync_r_tasks('proj_pltest',['C9BE6333-4E81-1B2A-B9E3-B7E3A84CB5DF']) ```