Example #1
0
    def __init__(self):
        self.pro = ts.pro_api(bluedothe.tushare_token)

        # pandas数据显示设置
        pd.set_option('display.max_columns', None)  # 显示所有列
        pd.set_option('display.max_rows', None)  # 显示所有行

        # mysql对象
        self.mysql = mysqlHelper(config.mysql_host, config.mysql_username, bluedothe.mysql_password,
                                 config.mysql_dbname)

        # pandas的mysql对象
        db_paras = {"host": config.mysql_host, "user": config.mysql_username, "passwd": bluedothe.mysql_password,
                    "dbname": config.mysql_dbname}
        #self.engine = create_engine('mysql+pymysql://{user}:{passwd}@{host}/{dbname}?charset=utf8'.format(**db_paras))
        self.engine = create_engine(f'mysql+pymysql://{config.mysql_username}:{bluedothe.mysql_password}@{config.mysql_host}/{config.mysql_dbname}?charset=utf8')
Example #2
0
    def __init__(self):
        #连接tdx接口
        self.api = TdxHq_API()
        if not self.api.connect('60.12.136.250', 7709):
            print("服务器连接失败!")

        # pandas数据显示设置
        pd.set_option('display.max_columns', None)  # 显示所有列
        #pd.set_option('display.max_rows', None)  # 显示所有行

        # mysql对象
        self.mysql = mysqlHelper(config.mysql_host, config.mysql_username,
                                 bluedothe.mysql_password, config.mysql_dbname)

        # pandas的mysql对象
        self.engine = create_engine(
            f'mysql+pymysql://{config.mysql_username}:{bluedothe.mysql_password}@{config.mysql_host}/{config.mysql_dbname}?charset=utf8'
        )
Example #3
0
    def __init__(self):
        #pandas数据显示设置
        pd.set_option('display.max_columns', None)  # 显示所有列
        pd.set_option('display.max_rows', None)  # 显示所有行

        # tushare对象
        self.tdxhelper = TdxHelper()
        self.tdx_local_helper = TdxLocalHelper()

        # mysql对象
        self.mysql = mysqlHelper(config.mysql_host, config.mysql_username,
                                 bluedothe.mysql_password, config.mysql_dbname)

        # pandas的mysql对象
        db_paras = {
            "host": config.mysql_host,
            "user": config.mysql_username,
            "passwd": bluedothe.mysql_password,
            "dbname": config.mysql_dbname
        }
        # self.engine = create_engine('mysql+pymysql://{user}:{passwd}@{host}/{dbname}?charset=utf8'.format(**db_paras))
        self.engine = create_engine(
            f'mysql+mysqlconnector://{config.mysql_username}:{bluedothe.mysql_password}@{config.mysql_host}/{config.mysql_dbname}?charset=utf8'
        )
Example #4
0
__author__ = "Bigcard"
__copyright__ = "Copyright 2018-2020"

import urllib
import requests
from bs4 import BeautifulSoup
import time
import random
from db.mysqlHelper import mysqlHelper
import threading

host = "localhost"
username = "******"
password = "******"
dbname = "kdata"
DBHelper = mysqlHelper(host, username, password, dbname)

heads = {
    'User-Agent':
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36'
}


def downIP(startPage, endPage):
    for i in range(startPage, endPage):
        #####################################################################################################
        # 爬66ip网的免费代理IP
        url = "http://www.66ip.cn/" + str(i) + ".html"
        response = requests.get(url, headers=heads)
        soup = BeautifulSoup(response.content.decode("gbk"), "lxml")
        # 找到属性"bordercolor"为"#6699ff"的table中的所有tr
Example #5
0
'''
    module description
    date: 2020/3/28
    数据库表初始化
'''
__author__ = "Bigcard"
__copyright__ = "Copyright 2018-2020"

import pandas as pd
from db.mysqlHelper import mysqlHelper
from config import config, bluedothe
from sqlalchemy import create_engine
from sqlalchemy.types import NVARCHAR, Integer, DateTime

mysql = mysqlHelper(config.mysql_host, config.mysql_username, bluedothe.mysql_password, config.mysql_dbname)
# pandas的mysql对象
engine = create_engine(f'mysql+pymysql://{config.mysql_username}:{bluedothe.mysql_password}@{config.mysql_host}/{config.mysql_dbname}?charset=utf8')

"""
CREATE DATABASE mydb default character set utf8mb4 collate utf8mb4_general_ci;
CREATE DATABASE mydb DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
create database mydb DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci
create database if not exists mydb default character set = 'utf8';
"""

create_database_common = "CREATE DATABASE if not exists {} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci"

drop_table_common = "drop table if exists {};"   #删除表
truncate_table_common = "truncate table {};"    #清空表数据
delete_table_common = "delete from {};"    #清空表数据