通过restful api向数据库写入测试数据
- curl -X POST "http://10.0.0.10:8001/api/v1/namespaces/default/services/demo/proxy/service/v1/user" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"birthDay\": \"2019-03-31T04:03:43.259Z\", \"createDate\": \"2019-03-31T04:03:43.259Z\", \"email\": \"A1@test.com\", \"name\": \"A1\", \"sex\": 0}"
- success
-
- curl -X POST "http://10.0.0.10:8001/api/v1/namespaces/default/services/demo/proxy/service/v1/user" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"birthDay\": \"2019-03-31T04:03:43.259Z\", \"createDate\": \"2019-03-31T04:03:43.259Z\", \"email\": \"B2@test.com\", \"name\": \"B2\", \"sex\": 1}"
- success
通过restful api查询刚才写入的数据
- curl -X GET "http://10.0.0.10:8001/api/v1/namespaces/default/services/demo/proxy/service/v1/users" -H "accept: application/json"
- [{"id":1,"name":"A1","email":"A1@test.com","sex":0,"birthDay":"2019-03-31T04:03:43.000+0000","createDate":"2019-03-31T04:03:43.000+0000"},{"id":2,"name":"B2","email":"B2@test.com","sex":1,"birthDay":"2019-03-31T04:03:43.000+0000","createDate":"2019-03-31T04:03:43.000+0000"}]
可以看到已经查询到刚才写入的测试数据。
通过命令行查看数据库的数据
- kubectl get pod
- NAME READY STATUS RESTARTS AGE
- demo-d4cd5bfdd-8qpfw 1/1 Running 0 7m54s
- mysql-6f76465564-j8dq2 1/1 Running 0 67m
-
- kubectl exec -it mysql-6f76465564-j8dq2 bash
- root@mysql-6f76465564-j8dq2:/usr/local/mysql# mysql -u root -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 422
- Server version: 5.7.4-m14 MySQL Community Server (GPL)
-
- Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
-
- Oracle is a registered trademark of Oracle Corporation and/or its
- affiliates. Other names may be trademarks of their respective
- owners.
-
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
- mysql>
- mysql> show databases;
- +--------------------+
- | Database |
- +--------------------+
- | information_schema |
- | demo |
- | mysql |
- | performance_schema |
- +--------------------+
- 4 rows in set (0.00 sec)
-
- mysql> use demo;
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
-
- Database changed
- mysql> show tables;
- +--------------------+
- | Tables_in_demo |
- +--------------------+
- | demo_users |
- | hibernate_sequence |
- +--------------------+
- 2 rows in set (0.00 sec)
-
- mysql> select * from demo_users;
- +----+---------------------+---------------------+-------------+------+------+
- | id | birth_day | create_date | email | name | sex |
- +----+---------------------+---------------------+-------------+------+------+
- | 1 | 2019-03-31 04:03:43 | 2019-03-31 04:03:43 | A1@test.com | A1 | 0 |
- | 2 | 2019-03-31 04:03:43 | 2019-03-31 04:03:43 | B2@test.com | B2 | 1 |
- +----+---------------------+---------------------+-------------+------+------+
- 2 rows in set (0.00 sec)
通过mysql命令行我们可以看到刚才的测试数据已经保存到数据库中。
(编辑:ASP站长网)
|