-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.c
54 lines (42 loc) · 1.03 KB
/
example.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include "mysqlex.h"
#include "mysqlex-util.h"
int main(int argc, char **argv)
{
struct mysqlex my_db;
struct mysqlex_resultset *rs;
mysql_library_init( argc, argv, NULL );
mysqlex_init( &my_db );
if ( !mysqlex_connect( &my_db, "localhost", "root", "123456", "lotterys", 3306, NULL, "utf8" ) )
{
printf( "%s\n", my_db.error );
return 0;
}
rs = mysqlex_query( &my_db, "SELECT * FROM lottery_data_513_257 where date = ?;", "i", 20170718 );
if ( mysqlex_next_result( rs ) )
{
if ( mysqlex_move_first( rs ) )
{
do
{
char value[15] = { 0 };
int32_t issue_no = mysqlex_get_field_int32( rs, "issue_no" );
mysqlex_get_field_string( rs, "value", value, sizeof( value ) );
printf( "issue_no :%d\n", issue_no );
printf( "value :%s\n", value );
}
while ( mysqlex_move_next( rs ) );
}
}
if ( rs )
{
mysqlex_resultset_free( rs );
}
mysqlex_close( &my_db );
return 0;
}