Create a new table under a database
CREATE TABLE TT (
ID INT not NULL PRIMARY KEY auto_increment,//Main table index, self-increment
' Name ' VARCHAR (20)
)
Storage mode
ALTER TABLE < table name > engine = InnoDB;
--------------------------------------------------------------------------
int db_connection;
Vuser_init ()
{
char** Result_row;
Char *server = "xxx.xx.x.xx"; The IP address of the database
Char *user = "ceshi001"; Database Access User Name
Char *password = "12345678"; Password
Char *database = "Ceshi"; Database name
int port = 3306; Access Port
int unix_socket = NULL;
int flags = 0;
int RC;
int index = 0;
rc = Lr_load_dll ("D:\\libmysql.dll"); Unpacking the package, please set your own directory
if (rc!=0)
{
Lr_error_message ("Load MySql.dll error!");
Lr_abort ();
}
Db_connection = Mysql_init (NULL);
if (db_connection = = NULL)
{
Lr_error_message ("Insufficient memory");
Lr_abort ();
}
rc = Mysql_real_connect (db_connection,server, user, password, database, port, unix_socket, flags);
if (rc = = NULL)
{
Lr_error_message ("Connect MySQL error! %s ", Mysql_error (db_connection));
Mysql_close (db_connection);
Lr_abort ();
}
return 0;
}
Action ()
{
int RC;
char** insertsql[222];
strcpy (Insertsql, "INSERT into TT (name) VALUES (' xxx ')");
Lr_start_transaction ("Insert");
rc = mysql_query (db_connection,insertsql);
Lr_end_transaction ("Insert", Lr_auto);
return 0;
}
Vuser_end ()
{
Mysql_close (db_connection);
return 0;
}
LoadRunner testing MySQL to perform an insert operation