Created
October 11, 2016 04:34
-
-
Save bgrainger/ef06cf4d784a0df414f1a9406c74ccd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using MySql.Data.MySqlClient; | |
namespace MySqlCompressBlob | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var csb = new MySqlConnectionStringBuilder | |
{ | |
Server = "localhost", | |
Database = "test", | |
UserID = "root", | |
Password = /* redacted */ | |
UseCompression = true, | |
}; | |
using (var connection = new MySqlConnection(csb.ConnectionString)) | |
{ | |
connection.Open(); | |
using (var cmd = new MySqlCommand("drop table if exists test.blobs; create table test.blobs(data longblob)", connection)) | |
cmd.ExecuteNonQuery(); | |
var bytes = new byte[16519389]; // no exception with new byte[16519388] | |
var random = new Random(1); | |
random.NextBytes(bytes); | |
using (var cmd = new MySqlCommand("insert into test.blobs(data) values(@data);", connection)) | |
{ | |
cmd.Parameters.AddWithValue("data", bytes); | |
cmd.ExecuteNonQuery(); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment