mysqlshでのアクセス
すぐ忘れるのでメモ
$ mysqlsh -u root -P 8000 Creating a Session to 'root@localhost:8000' Enter password: Node Session successfully established. No default schema selected. Welcome to MySQL Shell 1.0.9 Copyright (c) 2016, 2017, 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', '\h' or '\?' for help, type '\quit' or '\q' to exit. mysql-js> session <NodeSession:root@localhost:8000> mysql-js> \sql Switching to SQL mode... Commands end with ; mysql-sql> show schemas; +--------------------+ | Database | +--------------------+ | information_schema | | performance_schema | | world_x | | x_protocol_test | +--------------------+ 13 rows in set (0.02 sec) mysql-sql> use x_protocol_test; Query OK, 0 rows affected (0.01 sec) mysql-sql> show tables; +---------------------------+ | Tables_in_x_protocol_test | +---------------------------+ | alltypes | | bar | | bazz | | data_type_date | | data_type_datetime | | data_type_decimal | | data_type_decimal1 | | data_type_decimal2 | | data_type_enum | | data_type_time | | data_type_timestamp | | data_type_year | | foo | | foo_doc | | items | | mydoc | | products | | test_users | | users | | yyy | +---------------------------+ 20 rows in set (0.01 sec) mysql-sql> mysql-sql> \js Switching to JavaScript mode... mysql-js> session <NodeSession:root@localhost:8000> mysql-js> db = session.getSchema("x_protocol_test") <Schema:x_protocol_test> mysql-js> db.yyy.find().limit(1) [ { "_id": "4661c8c3e971b3fc4dcf4af757297cb5", "author": "Theodor Fontane", "currentlyReadingPage": 42, "isbn": "12345", "title": "xxxxx" } ] 1 document in set (0.01 sec) mysql-js> mysql-js> tbl = db.getTable("foo") <Table:foo> mysql-js> db.find().limit(1); Invalid object member find (AttributeError) mysql-js> db.select().limit(1); Invalid object member select (AttributeError) mysql-js> tbl.select().limit(1); +-----+-----+ | id | v | +-----+-----+ | 123 | xyz | +-----+-----+ 1 row in set (0.00 sec) mysql-js>