Skip to content

Commit

Permalink
解决 数据重跑问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
“yhy” committed Jul 9, 2020
1 parent a0de9c6 commit 768e580
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ docker.io/mariadb:latest

```
docker exec -it stock bash
cat /tmp/jupyter-stderr*.log
查看登录 token 问题:
jupyter notebook list
# 就可以看到 token 了,然后可以登录了。
```

Expand Down Expand Up @@ -151,3 +155,19 @@ CREATE TABLE `user_stock` (
```
sh startStock.sh 1
```

### 8,解决跑数据问题

```
# 通过数据库链接 engine。
def conn():
try:
db = MySQLdb.connect(MYSQL_HOST, MYSQL_USER, MYSQL_PWD, MYSQL_DB, charset="utf8")
# db.autocommit = True
except Exception as e:
print("conn error :", e)
db.autocommit(on=True)
return db.cursor()
```

之前升级过代码,造成 db.cursor() 问题。
11 changes: 8 additions & 3 deletions libs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ def engine_to_db(to_db):
return engine


# 通过数据库链接 engine。
def conn():
db = MySQLdb.connect(MYSQL_HOST, MYSQL_USER, MYSQL_PWD, MYSQL_DB, charset="utf8")
# db.autocommit(on=True)
return db
try:
db = MySQLdb.connect(MYSQL_HOST, MYSQL_USER, MYSQL_PWD, MYSQL_DB, charset="utf8")
# db.autocommit = True
except Exception as e:
print("conn error :", e)
db.autocommit(on=True)
return db.cursor()


# 定义通用方法函数,插入数据库表,并创建数据库主键,保证重跑数据的时候索引唯一。
Expand Down

0 comments on commit 768e580

Please sign in to comment.