gpt4 book ai didi

mysql - 如何使用QT在MYSQL数据库中存储文本文件?

转载 作者:行者123 更新时间:2023-11-29 20:21:52 26 4
gpt4 key购买 nike

我有一个表,其中有两列:ID、FILE;FILE列具有BLOB类型;我想将完整文件存储在数据库中,而不是文件的内容。我想稍后将该文件下载为 file_name.txt

这就是我尝试的方法,但插入后文件为空;

 query.exec("INSERT INTO test(ID, FILE) VALUES(1, LOAD_FILE('/home/nemeth/Documents/list.txt'));

最佳答案


根据 MySQL documentation on LOAD_FILE() ,文件必须满足一些条件才能加载。不仅是本地的,而且还有权限和其他东西。

LOAD_FILE(file_name)

Reads the file and returns the file contents as a string. To use this function, the file must be located on the server host, you must specify the full path name to the file, and you must have the FILE privilege. The file must be readable by all and its size less than max_allowed_packet bytes. If the secure_file_priv system variable is set to a nonempty directory name, the file to be loaded must be located in that directory.

If the file does not exist or cannot be read because one of the preceding conditions is not satisfied, the function returns NULL.

The character_set_filesystem system variable controls interpretation of file names that are given as literal strings.

您也尝试过搜索一下吗?... Lookie here :p

关于mysql - 如何使用QT在MYSQL数据库中存储文本文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39470388/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com