【发布时间】:2020-03-08 21:08:37
【问题描述】:
我有一张有 97972561 行的大桌子。我想将表格导出到一个文件(txt 或 json 或 pickle 或任何东西)中,这对于我的后续操作来说更容易。我该怎么做?我尝试查询“select * from the_table”并将结果保存到文件中,但是需要很长时间并且失败。我也尝试过“进入 outfile”,但我的“secure_file_priv”为空,无法更改。
mydb = mysql.connector.connect(
host="localhost",
user="username",
passwd="xxxxxx",
db="mydb")
cur = mydb.cursor()
query = "SELECT * FROM PREDICATION"
cur.execute(query)
all_recordings = cur.fetchall()
mydb.close()
# save all recordings to a pickle file
with open('recordings.pkl', 'wb') as f:
pickle.dump(all_recordings, f)
我目前在终端 (Mac) 和工作台 6.3 中使用 mysql 服务器 8.0.18。任何帮助将不胜感激!
【问题讨论】:
标签: mysql mysql-workbench mysql-python