本文整理汇总了Python中collector.Collector.collect_finance方法的典型用法代码示例。如果您正苦于以下问题:Python Collector.collect_finance方法的具体用法?Python Collector.collect_finance怎么用?Python Collector.collect_finance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collector.Collector
的用法示例。
在下文中一共展示了Collector.collect_finance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from collector import Collector [as 别名]
# 或者: from collector.Collector import collect_finance [as 别名]
class DBInitializer:
def __init__(self):
conf_path = "%s/FDM/FDM.conf"%(os.getcwd())
self.__conf = ConfigParser.ConfigParser()
self.__conf.read(conf_path)
self.__conn = None
self.collector = Collector()
def start(self):
host = self.__conf.get("mysql", "host")
user = self.__conf.get("mysql", "user")
password = self.__conf.get("mysql", "password")
charset = self.__conf.get("mysql", "charset")
db = self.__conf.get("mysql", "db")
self.__conn = ConnManager.get_conn()
cursor = self.__conn.cursor()
try:
cursor.execute("use %s"%(db))
except:
cursor.execute("create database %s default character set utf8"%(db))
cursor.execute("use %s"%(db))
cursor.close()
self.__do_init(self.__conn)
def __do_init(self, conn):
self.__maybe_init_stocks_table(conn)
self.__maybe_init_bonus_table(conn)
self.__maybe_init_finance_table(conn)
self.__maybe_init_market_table(conn)
def __maybe_init_stocks_table(self, conn):
cursor = conn.cursor()
if cursor.execute('show tables like "stock_information"') == 0:
print "init stock information..."
sql_path = "%s/FDM/sqls/create_stocks_table.sql"%(os.getcwd())
sql_file = open(sql_path, "r")
create_table_sql = sql_file.read()
sql_file.close()
cursor.execute(create_table_sql)
self.collector.collect_stock_information()
cursor.close()
def __maybe_init_bonus_table(self, conn):
cursor = conn.cursor()
if cursor.execute('show tables like "bonus"') == 0:
print "init bonus..."
sql_path = "%s/FDM/sqls/create_bonus_table.sql"%(os.getcwd())
sql_file = open(sql_path, "r")
create_bonus_sql = sql_file.read()
sql_file.close()
cursor.execute(create_bonus_sql)
self.collector.collect_bonus()
cursor.close()
def __maybe_init_finance_table(self, conn):
cursor = conn.cursor()
if cursor.execute('show tables like "finance"') == 0:
print "init finance..."
sql_path = "%s/FDM/sqls/create_finance_table.sql"%(os.getcwd())
sql_file = open(sql_path, "r")
create_finance_sql = sql_file.read()
sql_file.close()
cursor.execute(create_finance_sql)
self.collector.collect_finance()
cursor.close()
def __maybe_init_market_table(self, conn):
cursor = conn.cursor()
if cursor.execute('show tables like "market"') == 0:
print "init market..."
sql_path = "%s/FDM/sqls/create_market_table.sql"%(os.getcwd())
sql_file = open(sql_path, "r")
create_table_sql = sql_file.read()
sql_file.close()
cursor.execute(create_table_sql)
self.collector.collect_market(XUEQIU)
cursor.close()