我想在 MySQL 查询中压缩 MySQL 结果或字符串,并将结果发送到 delphi 应用程序。我用它来加速连接。 问题是如何在 delphi 中从 MySQL 结果中解压缩字符串。
这是我的示例查询
Select Compress(AColumn), Compress(BColumn) from ATable
最佳答案
压缩是为了存储
MySQL中的compress
关键字并不是为了减少网络流量,而是为了减少存储需求。
压缩的细节没有记录,并且可能因服务器而异。
COMPRESS(string_to_compress)
Compresses a string and returns the result as a binary string. This function requires MySQL to have been compiled with a compression library such as zlib. Otherwise, the return value is always NULL. The compressed string can be uncompressed with
UNCOMPRESS()
.
请注意,解压缩的能力取决于编译 MySQL 版本时使用的压缩库。
如果要进行网络压缩,请修改连接字符串
如果你想压缩你在连接设置中指定的网络数据:
将以下字符串添加到 Properties
属性。
UseCompression = true;
可以在此处找到所有连接属性的列表:
https://www.connectionstrings.com/mysql/
可在此处找到更多信息:http://dev.mysql.com/doc/refman/5.0/es/connector-net-examples-mysqlconnection.html#connector-net-examples-mysqlconnection-connectionstring
(请注意,此信息很旧,但我正在为较新版本调整 url,导致 404 页面未找到错误)。
请注意,在 Delphi 中,connectionstring
主要由属性归档:
- 数据库
- 端口
- 密码
等等
在 Properties
属性中,您只提供那些 Delphi 尚未在其其他属性中涵盖的 ConnectionString
选项。多个参数由 ;
分隔。
进一步的并发症
不同的组件包对您可以放入 ConnectionString 的额外数据使用不同的名称。
ZEOS 称之为属性
其他人称之为其他事物。
关于mysql - 如何在delphi中解压mysql字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22602218/