Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1) use pymysql to replace the obsoleted MySQLDb; 2) fix the empty ret… #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jobs/guess_indicators_daily_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ def apply_guess(tmp, stock_column):
date = tmp["date"]
code = tmp["code"]
date_end = datetime.datetime.strptime(date, "%Y%m%d")
date_start = (date_end + datetime.timedelta(days=-100)).strftime("%Y-%m-%d")
date_end = date_end.strftime("%Y-%m-%d")
date_start = (date_end + datetime.timedelta(days=-100)).strftime("%Y%m%d")
date_end = date_end.strftime("%Y%m%d")
# print(code, date_start, date_end)
# open, high, close, low, volume, price_change, p_change, ma5, ma10, ma20, v_ma5, v_ma10, v_ma20, turnover
# 使用缓存方法。加快计算速度。
Expand Down
6 changes: 3 additions & 3 deletions libs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import time
import sys
import os
import MySQLdb
import pymysql
from sqlalchemy import create_engine
from sqlalchemy.types import NVARCHAR
from sqlalchemy import inspect
Expand Down Expand Up @@ -45,11 +45,11 @@ def engine_to_db(to_db):
# 通过数据库链接 engine。
def conn():
try:
db = MySQLdb.connect(MYSQL_HOST, MYSQL_USER, MYSQL_PWD, MYSQL_DB, charset="utf8")
db = pymysql.connect(host=MYSQL_HOST, port=3306, user=MYSQL_USER, password=MYSQL_PWD, db=MYSQL_DB, charset="utf8")
# db.autocommit = True
except Exception as e:
print("conn error :", e)
db.autocommit(on=True)
db.autocommit(True)
return db.cursor()


Expand Down