This article is a mirror article of machine translation, please click here to jump to the original article.

View: 14562|Reply: 5

[Interface] C# GZipStream interacts with the database and performs data compression and decompression

[Copy link]
Posted on 12/26/2018 1:36:23 PM | | |
This post was last edited by sgFengSu on 2018-12-27 16:20

Recently, when doing a project, I encountered compressing the database data into .gz files, and obtaining the compressed file for decompression and writing to the database, it is recommended to write and decompress and decompress separately into classes to call, and attach the attachment to the class found above, PS: If you use SFTP, you need to add Renci.SshNet.dll


Read sqlserver data and compress files, the main technology GZipStream compression, see https://www.itsvse.com/thread-4240-1-1.html for details


Unzip the file and write it to sqlserver, the main technique
For more information on GZipStream, please visit: https://www.itsvse.com/thread-4831-1-1.html
SqlBulkCopy, for bulk import
If there is a header, use restOfStream.StartsWith("1") to remove the header, see the last code (the old code did not use SqlBulkCopy, but wrote by executing the insert statement multiple times)

Old code - unzip the file and write to the database



Score

Number of participants1MB+1 contribute+1 Collapse reason
Little scum + 1 + 1 Very powerful!

See all ratings





Previous:Elasticsearch deletes and indexes all document data
Next:Martial arts teaching Qigong points and other martial arts (last update)
 Landlord| Posted on 12/26/2018 1:38:29 PM |
I forgot to upload the attachment

压缩及解压缩.zip (167.94 KB, Number of downloads: 6, Selling price: 1 Grain MB)
Posted on 12/26/2018 2:07:16 PM |
This is very useful for transferring the database to another server, improving disaster recovery and preventing data loss on a single machine.

I remember that the automatic backup database of Ruijie background is uploaded to another server through the FTP protocol, but the database is not compressed.

I don't know how the landlord uses GZipStream to compress, for example: what is the size of a 1G file after compression?
 Landlord| Posted on 12/26/2018 10:12:41 PM |
Xiao Zhazha Posted on 2018-12-26 14:07
This is very useful for transferring the database to another server, improving disaster recovery and preventing data loss on a single machine.

Remember that Ruijie's automatic background backup database is ...

1G files can be compressed to about 5M
By the way, is there a function on the website to expand and contract code, so there is too much code at a glance
Posted on 12/27/2018 1:52:11 PM |
sgFengSu posted on 2018-12-26 22:12
1G files can be compressed to about 5M
By the way, is there a function on the website to expand and contract code, so there is too much code at a glance...

Well, there is no code to expand the contraction function...

It's so amazing that 1G can be compressed to 5M, it's a bit unbelievable
 Landlord| Posted on 12/27/2018 2:46:57 PM |
Xiao Zhazha Posted on 2018-12-27 13:52
Well, there is no code to expand the contraction function...

It's amazing that 1G can be compressed to 5M, it's a bit unbelievable...

Expand contraction this can have
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com