Esempio n. 1
0
 private void UserHandlTest(IApplicationBuilder app)
 {
     app.Run(async ctx =>
     {
         using (var connection = new MySqlConnector.MySqlConnection("server=192.168.3.125;database=go_testdb;uid=root;pwd=123456;charset='utf8';SslMode=None"))
         {
             await connection.OpenAsync();
             using var command      = connection.CreateCommand();
             command.CommandText    = "select id,name,age,birthday from users where id = 1";
             command.Connection     = connection;
             command.CommandTimeout = 1;
             var reader             = await command.ExecuteReaderAsync();
             //_ = await connection.QueryFirstAsync<User>("select id,name,age,birthday from users");
         }
     });
 }
Esempio n. 2
0
        public void GlobalSetup()
        {
            using (var connection = new MySqlConnector.MySqlConnection(s_connectionString))
            {
                connection.Open();
                using (var cmd = connection.CreateCommand())
                {
                    cmd.CommandText = @"
create schema if not exists benchmark;

drop table if exists benchmark.integers;
create table benchmark.integers (value int not null primary key);
insert into benchmark.integers(value) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);

drop table if exists benchmark.blobs;
create table benchmark.blobs(
rowid integer not null primary key auto_increment,
`Blob` longblob null
);
insert into benchmark.blobs(`Blob`) values(null), (@Blob1), (@Blob2);";

                    // larger blobs make the tests run much slower
                    AddBlobParameter(cmd, "@Blob1", 75000);
                    AddBlobParameter(cmd, "@Blob2", 150000);

                    cmd.ExecuteNonQuery();
                }
            }

            s_connectionString += ";database=benchmark";

            var mySqlData = new MySql.Data.MySqlClient.MySqlConnection(s_connectionString);

            mySqlData.Open();
            m_connections.Add("MySql.Data", mySqlData);

            var mySqlConnector = new MySqlConnector.MySqlConnection(s_connectionString);

            mySqlConnector.Open();
            m_connections.Add("MySqlConnector", mySqlConnector);

            Connection = m_connections[Library];
        }