mysql-source.td 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Test creating a MySQL source using SSH
  10. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  11. > CREATE CONNECTION mysql TO MYSQL (
  12. HOST mysql,
  13. USER root,
  14. PASSWORD SECRET mysqlpass,
  15. SSH TUNNEL thancred
  16. );
  17. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  18. $ mysql-execute name=mysql
  19. DROP DATABASE IF EXISTS dummyschema;
  20. CREATE DATABASE dummyschema;
  21. USE dummyschema;
  22. CREATE TABLE dummy (f1 INTEGER);
  23. INSERT INTO dummy VALUES (1), (2);
  24. COMMIT;
  25. > CREATE SOURCE mysql_source FROM MYSQL CONNECTION mysql;
  26. > CREATE TABLE dummy FROM SOURCE mysql_source (REFERENCE dummyschema.dummy);
  27. > SELECT COUNT(*) FROM dummy;
  28. 2
  29. $ mysql-execute name=mysql
  30. INSERT INTO dummy VALUES (3);
  31. > SELECT * FROM dummy;
  32. 1
  33. 2
  34. 3