예제 #1
0
def getAndConvertCostData(dateDetail):
    dbo = DBOperation.DBOperation()
    #rawData = dbo.customizedFetch(sqlCommand)
    #rawData = dbo.fetchAllData('cost')
    cmd = makeCommand(dateDetail)
    rawData = dbo.customizedFetch(cmd)

    (gridData, gridLabel) = decryptionList(rawData)
    return gridData, gridLabel
예제 #2
0
    def getAllRawData(self):
        cleanedTimeList = []
        dbo = DBOperation.DBOperation()
        try :
            dbo.fetchAllData('cost')
            (gridData,gridLabel) = cmm.getAndConvertCostData(("","","",))
        except :
            gridLabel = ""

        for item in gridLabel:
            #print "item : >%s<"%item
            cleanedTimeList.append(item[:item.rfind(' ')])

        cleanedTimeList = list(set(cleanedTimeList))
        #print "cleanedTimeList : ",cleanedTimeList
        return cleanedTimeList
예제 #3
0
    def onAddCost(self, event):
        #value = self.textList[3].GetLabelText()
        value = self.textList[3].GetValue()
        comments = self.textList[5].GetLabelText()
        if '.' in str(value):
            value = value[:str(value).rfind('.')]
        if not str(value).isdigit() or 0 == len(str(value)):
            self.textList[6].SetLabel("value should be numbers...")

        else:
            name = ed.enDecryption.encryption(self.costNameForDB)
            value = ed.enDecryption.encryption(value)
            comments = ed.enDecryption.encryption(comments)
            curTime = cmm.getTimeAndWeek()[0]

            insertValue = (name, value, comments, curTime)

            db = dbo.DBOperation()
            db.insertData('cost', insertValue)
            self.Destroy()
예제 #4
0
def InitStockDB(file):

    #     logger = LoggerFactory.getLogger("InitStockDB")
    #     loggerBasicData = LoggerFactory.getLogger("GetStockBasicData")

    stocklist = StockDataByTX.GetAllStockCode(file)

    mytime = "str_to_date('%s'," % time.strftime('%Y-%m-%d') + "'%Y-%m-%d')"

    dboper = DBOperation.DBOperation()

    counter = 0

    for stock in stocklist:

        code = stock['code']

        stockBasicData = StockDataByTX.GetStockBasicData(code)

        if stockBasicData is not None:

            LoggerFactory.info("InitStockDB",
                               "正在处理:  %s" % stockBasicData['name'])

            if stockBasicData['mount'] == 0:
                status = 0
            else:
                status = 1

            sql = "insert into stocks(code, codealias, name, industry, circulated, totalstock, status, peg, lyr, mtime, area)  values('%s', '%s', '%s', '%s', %0.2f, %0.2f, %d, %0.2f, %0.2f, %s, '%s' )" \
                    % (stockBasicData['code'], stockBasicData['codealias'], stockBasicData['name'], stock['industry'], stockBasicData['circulated_stock'], \
                      stockBasicData['total_stock'], status, stockBasicData['peg'], stockBasicData['lyr'], mytime, stock['area'])

            dboper.sqlExecute(sql)

            counter = counter + 1

    LoggerFactory.info(
        "InitStockDB",
        "Stock DB initialization has completed! There're %s Stocks created into the Database!"
        % str(counter))
예제 #5
0
    def blackBoxEnter(self, event):
        command = self.blackBox.GetValue()
        command.strip()
        if 'costDate' not in command:
            varOld = ""
            if 'like' in command or 'LIKE' in command:
                varOld = command[command.find('\'') + 1:command.rfind('%')]
            elif '=' in command:
                varOld = command[command.find('\'') + 1:command.rfind('\'')]
            varNew = ed.enDecryption.encryption(varOld)
            varNew.strip()
            command = command.replace(varOld, varNew)

        dbo = DBOperation.DBOperation()
        raw = dbo.customizedFetch(command)
        (data, label) = cmm.decryptionList(raw)
        total = cmm.calculatingTotalCost(data)
        self.totalBoxList[1].SetValue(str(total))
        table = basicTable(data,
                           rowLabel=label,
                           colLabel=("Name", "Money", "Comments"))
        self.grid.SetTable(table)
        self.__setGridAttributes()
        self.Refresh()
예제 #6
0
파일: HisStock.py 프로젝트: HarryTu/PyStock
        LoggerFactory.error("DailyHisData", "股票代码信息获取失败.....")


def InsertHisData(code, dboper):

    realtimeData = StockDataByTX.CollectRealTimeData(code)

    if realtimeData is not None:

        LoggerFactory.info("InsertHisData", "正在处理: %s" % realtimeData['code'])

        DBDataHandle.InsertHisData(dboper, realtimeData)

    else:

        LoggerFactory.error("InsertHisData", "股票: %s 的相关信息获取失败..." % code)


if "__name == __main__":

    #     week_day = datetime.date.today().weekday()
    #
    #     if ( week_day == 5 or week_day == 6 ):
    #
    #         LoggerFactory.info("HisStock", "Today is weekend, no historic data need to be collected.....")
    #
    #     else:

    dboper = DBOperation.DBOperation()
    DailyHisData(dboper)
예제 #7
0
import DBOperation

db = DBOperation.DBOperation()

db.OpenDB("./test.db")  #测试数据库
print(db.getPairs())
db.addPair(1, "a", "b", "c")
db.addPair(2, "a", "bsd", "csd")
print(db.getPairs())
db.delPair(1)
db.updatePair(2, "GoodWe 5kw ES", "INV", "GoodWe_es_v3")
print(db.getPairs())
예제 #8
0
import DBOperation
import logging
import json
import io
import os
import sys
import math
from bs4 import BeautifulSoup

#Call Function here
try:
    
    if __name__ == '__main__':
        HttpRequest=HttpHandler.HttpHandler()
        ObjStringUtil=StringHelper.StringHelper()
        ObjDbOperations=DBOperation.DBOperation()
        objRegularExpressionParser=RegularExpressionParser.RegularExpressionParser()
        infoLavel=Config.Config.LogLevel
        logging.info('Completed configuring logger()!')
        
        isRedirection=True
        Cookies=""
        Refer=""
        ResponseCookie=""
        redirectionURL=""
        # Category & Subcategory
        lastURLS = [None] * 2
        if len(sys.argv) > 1 and sys.argv[1] == "continue":
            print("\nContinuing script from last URL\n")
            # Get last URL
            with open('lastURL.txt') as f: