如何使用python格式化SQLite3中的列宽?

2024-09-28 19:24:05 发布

您现在位置:Python中文网/ 问答频道 /正文

数据库中的file path列被切断,我还没有找到任何说明如何在python中指定列宽的文档。我正在用熊猫在终端上打印数据库。你知道吗

数据库打印输出:

                                                    Path     Status                 Time
0                                      pytest_file.c       Safe  2018-06-11 10:33:29
1  /Users/me/Documents/to_scan/SSpres...  File Sent  2018-06-11 10:45:05
2  /Users/me/Downloads/SampleData/Eli...  File Sent  2018-06-11 10:45:33
3  /Users/me/Downloads/SampleData/Eli...  File Sent  2018-06-11 10:45:34
4  /Users/me/Downloads/SampleData/Lec...  File Sent  2018-06-11 10:45:35
5  /Users/me/temp/ess-dive-volumes/var...       Safe  2018-06-11 11:46:02
6  /Users/me/temp/ess-dive-volumes/var...       Safe  2018-06-11 11:46:18
7  /Users/me/temp/ess-dive-volumes/var...       Safe  2018-06-11 11:46:34
8  /Users/me/temp/ess-dive-volumes/var...       Safe  2018-06-11 11:46:50

打印数据库代码:

con = sqlite3.connect(data_base)
return pd.read_sql_query('''SELECT Path, Status, Time FROM files_db''', con)

print(print_db(database))

Tags: path数据库vardownloadsuserstempsentfile
1条回答
网友
1楼 · 发布于 2024-09-28 19:24:05

原来熊猫是限制因素,而不是sqlite3。我通过手动将pd.options.display.max_colwidth设置为255解决了这个问题。你知道吗

解决这个问题的一条线是:

pd.options.display.max_colwidth = 255

相关问题 更多 >