trying to write to database, but it does not
using c++ code, tried
mysql_query(PA, "INSERT INTO mydatabae VALUES(1)");
but nothing.
found:
-- create
CREATE TABLE EMPLOYEE (
empId INTEGER PRIMARY KEY,
name TEXT NOT NULL,
dept TEXT NOT NULL
);
-- insert
INSERT INTO EMPLOYEE VALUES (0001, 'Clark', 'Sales');
tried:
mysql_query(PA, "CREATE TABLE A_axis(axis INTEGER PRIMARY KEY)");
made table.
tried:
mysql_query(PA, "INSERT INTO A_axis VALUES(1)");
mysql_query(PA, "INSERT INTO A_axis(1)");
result:
MariaDB [mydatabase]> SHOW TABLES;
+----------------------+
| Tables_in_mydatabase |
+----------------------+
| A_axis |
+----------------------+
1 row in set (0.000 sec)
maybe using wrong mysql command to see what is in table. definitely not understanding something.
how to write to database, and how to see what is in database?
-----------------------------------------------------------------------
03/03/24
MariaDB [mydatabase]> SELECT * FROM A_axis;
+------+
| axis |
+------+
| 1 |
+------+
1 row in set (0.000 sec)
same output, even after changing code:
mysql_query(PA, "CREATE TABLE A_axis(axis INTEGER PRIMARY KEY)");
int b = mysql_query(PA, "INSERT INTO A_axis(3)");
b = mysql_query(PA, "INSERT INTO A_axis(2)");
std::cout << "b = " << b << '\n';
and:
std::cout << "b = " << b << '\n';
is:
b = 1
INSERT INTO A_axis(1)
has to be
INSERT INTO A_axis(axis) VALUE (1)