Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building SQL-Free Applications with MySQL REST ...

Avatar for lefred lefred
November 04, 2025
22

Building SQL-Free Applications with MySQL REST Service

In this hands-on workshop, we will explore the new MySQL REST Service — a powerful component (currently in preview) that enables direct HTTP/JSON access to MySQL data without writing SQL.
Using MySQL Shell and the REST Service, participants will learn how to:
- Expose MySQL tables, views, and procedures as RESTful endpoints
- Perform CRUD operations and query data using standard HTTP verbs
- Integrate MySQL seamlessly with web, mobile, and serverless applications
- Secure endpoints with authentication, roles, and fine-grained access control
- Automate REST configuration and deployment using MySQL Shell scripting

This session was delivered at Contech by RoOUG

Avatar for lefred

lefred

November 04, 2025
Tweet

Transcript

  1. Frédéric Descamps Community Manager Oracle MySQL Contech 2025 - November

    2025 Use MySQL Without SQL Discover the new REST API [ W O R K S H O P ]
  2. • @lefred • @lefredbe.bsky.social • @[email protected] • @lefred14:matrix.org • MySQL

    Evangelist • using MySQL since version 3.20 • devops believer • living in • h�ps://lefred.be Frédéric Descamps Copyright @ 2025 Oracle and/or its affiliates. 3
  3. • Introduction to MySQL REST Service (MRS) • Installation of

    MySQL Labs with MRS • Installation of MySQL Shell for Visual Studio Code • Loading sample database • Building RESTful APIs with MRS ◦ with MySQL Shell for VS Code ◦ with SQL in MySQL Shell • Using the Python SDK • Q&A Session Workshop Agenda Copyright @ 2025 Oracle and/or its affiliates. 5
  4. • MRS is built on the concept of ORDS, but

    targeting the strengths of MySQL ◦ focus on MySQL performance ◦ focus on MySQL scalability ◦ MySQL/HeatWave metadata storage - no dependencies on an Oracle DB instance • ORDS & APEX compatible • Developer oriented ◦ low learning curve ◦ easy to learn and use ◦ beginner friendly ◦ manageable via GUI or code ... Copyright © 2023, Oracle and/or its affi liates MySQL Router MySQL Router MySQL Router MySQL Router … MySQL Shell OAuth2 Service MySQL/HeatWave Client App Client App Client App … Client App Client App Client App … Client App Client App Client App … Client App Client App Client App MRS Plugin Auth HTTPS Server SQL Load Balancer Load Balancer MySQL REST Service (MRS) - Architecture ... MRS Metadata Schema Application Data MySQL Shell for VS Code MySQL REST Service (MRS) Fast, Secure HTTPS Access for MySQL Data Copyright @ 2025 Oracle and/or its affiliates. 7
  5. RESTful Web Services • auto REST for tables, view, procedures

    and functions • {JSON} responses with paged results • developer support (GUI, CLI, API) • support for popular OAuth2 services Powerful REST Data Mapping • full SQL support for joins and nested JSON REST endpoints • Visual Data Mapping Editor ◦ build complex JSON structures with a �ew clicks • SQL & SDK interface preview MySQL REST Service (MRS) Features Overview Copyright @ 2025 Oracle and/or its affiliates. 8
  6. Full SQL Support & SDK API • fully manageable through

    SQL • tailored SDK for all RESTful Endpoints • popular, Prisma-like API, like prototyping TypeScript SDK API whith live prototyping of REST queries Fully manageable through SQL MySQL REST Service (MRS) Features Overview (2) Copyright @ 2025 Oracle and/or its affiliates. 9
  7. MySQL REST Service (MRS) Visual REST Mapping View Editor Intuitive

    WYSIWYG Editor to design REST Mappings • creation of complex mappings with a few clicks • automatic database schema analysis • SQL Preview Copyright @ 2025 Oracle and/or its affiliates. 10
  8. Installation: MySQL Server We will use MySQL Labs 9.5.0 with

    MRS included that you can download from: h�ps://labs.mysql.com/ And we will use docker in the examples but you can install it natively on your OS as well. Copyright @ 2025 Oracle and/or its affiliates. 13
  9. Installation: MySQL Server (using docker) $ $ docker docker load

    load --input --input mysql-community-9.5.0-labs-mrs-docker.tar.gz mysql-community-9.5.0-labs-mrs-docker.tar.gz $ $ docker docker image list image list REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE localhost/mysql/mysql-server localhost/mysql/mysql-server 9.5 9.5-amd64 4eb91d97a28d -amd64 4eb91d97a28d 2 2 hours ago 905M hours ago 905M $ $ docker docker run run -d -d --name --name mrs mrs -e -e MYSQL_ROOT_PASSWORD MYSQL_ROOT_PASSWORD= =contech contech \ \ -p -p 3306 3306:3306 :3306 -p -p 33060 33060:33060 :33060 -p -p 33061 33061:33061 :33061 \ \ localhost/mysql/mysql-server:9.5-amd64 localhost/mysql/mysql-server:9.5-amd64 $ $ docker docker ps ps Copyright @ 2025 Oracle and/or its affiliates. 14
  10. Installation: MySQL Server (using docker) (2) Now we need to

    create a user that will be able to connect from your machine to to database server in the container: $ $ docker docker exec exec -it -it mrs mysql mrs mysql -uroot -uroot -p -p Enter password: contech Enter password: contech Welcome to the MySQL monitor. Commands end with Welcome to the MySQL monitor. Commands end with ; ; or or \ \g. g. Your MySQL connection Your MySQL connection id id is is 10 10 Server version: Server version: 9.5 9.5.0-labs-mrs-15 MySQL Community Server - GPL .0-labs-mrs-15 MySQL Community Server - GPL mysql mysql> > create user contech identified by create user contech identified by 'contech' 'contech'; ; Query OK, Query OK, 0 0 rows affected rows affected ( (0.018 0.018 sec sec) ) mysql mysql> > grant all privileges on *.* to contech with grant option grant all privileges on *.* to contech with grant option; ; Query OK, Query OK, 0 0 rows affected rows affected ( (0.014 0.014 sec sec) ) Copyright @ 2025 Oracle and/or its affiliates. 15
  11. Installation: MySQL Shell for Visual Studio Code You need to

    install Visual Studio Code and then the MySQL Shell extension from the marketplace. Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter: ext ext install install Oracle.mysql-shell-for-vs-code Oracle.mysql-shell-for-vs-code Copyright @ 2025 Oracle and/or its affiliates. 16
  12. Connecting to MySQL Server (2) If we prefer to use

    MySQL Shell from command line, we can do it like this if we have it installed (from h�ps://dev.mysql.com/ downloads/shell/): $ mysqlsh mysql://[email protected]:3306 $ mysqlsh mysql://[email protected]:3306 Please provide the password Please provide the password for for '[email protected]:3306' '[email protected]:3306': : ******* ******* Save password Save password for for '[email protected]:3306' '[email protected]:3306'? ? [ [Y Y] ]es/ es/[ [N N] ]o/Ne o/Ne[ [v v] ]er er ( (default No default No) ): : yes yes MySQL Shell MySQL Shell 9.5 9.5.0 .0 Type Type '\help' '\help' or or '\?' '\?' for for help help; ; '\quit' '\quit' to exit. to exit. Creating a Classic session to Creating a Classic session to '[email protected]:3306' '[email protected]:3306' Fetching global names Fetching global names for for auto-completion auto-completion.. ... Press ^C to stop. . Press ^C to stop. Your MySQL connection Your MySQL connection id id is is 12 12 Server version: Server version: 9.5 9.5.0-labs-mrs-15 MySQL Community Server - GPL .0-labs-mrs-15 MySQL Community Server - GPL No default schema selected No default schema selected; ; type type \ \use use < <schema schema> > to to set set one. one. MySQL MySQL> > Copyright @ 2025 Oracle and/or its affiliates. 21
  13. Loading Sample Database: Sakila We will use the Sakila sample

    database that you can download from: h�ps://downloads.mysql.com/docs/sakila-db.zip The Sakila sample database was initially developed by Mike Hillyer, a former member of the MySQL AB documentation team. It is intended to provide a standard schema that can be used for examples in books, tutorials, articles, samples, and so forth. The Sakila sample database also serves to highlight features of MySQL such as Views, Stored Procedures, and Triggers. Copyright @ 2025 Oracle and/or its affiliates. 23
  14. Loading Sample Database: Sakila We will use the Sakila sample

    database that you can download from: h�ps://downloads.mysql.com/docs/sakila-db.zip The Sakila sample database was initially developed by Mike Hillyer, a former member of the MySQL AB documentation team. It is intended to provide a standard schema that can be used for examples in books, tutorials, articles, samples, and so forth. The Sakila sample database also serves to highlight features of MySQL such as Views, Stored Procedures, and Triggers. Download it and unzip it! Copyright @ 2025 Oracle and/or its affiliates. 23
  15. Loading Sample Database: Sakila (2) In MySQL Shell for VS

    Code, open the sakila-schema.sql �le: Copyright @ 2025 Oracle and/or its affiliates. 24
  16. Loading Sample Database: Sakila (2) Then load the sakila-data.sql �le:

    Copyright @ 2025 Oracle and/or its affiliates. 26
  17. Creating the REST metadata The very �rst step for the

    MySQL REST Service component to work is to create the metadata schema. We perform this operation even before loading the component. Copyright @ 2025 Oracle and/or its affiliates. 29
  18. Creating the REST metadata The very �rst step for the

    MySQL REST Service component to work is to create the metadata schema. We perform this operation even before loading the component. This operation can be done in SQL like this: SQL SQL> > CONFIGURE REST METADATA CONFIGURE REST METADATA; ; But we will do it using MySQL Shell for VS Code as it automates more things for us. Copyright @ 2025 Oracle and/or its affiliates. 29
  19. Loading the MRS Component This lab version provides a MRS

    component pre-installed but not yet loaded. This is a nice enhancement as you don't need to use MySQL Router as middleware between your application and the database server to provide RESTful services. Copyright @ 2025 Oracle and/or its affiliates. 34
  20. Loading the MRS Component This lab version provides a MRS

    component pre-installed but not yet loaded. This is a nice enhancement as you don't need to use MySQL Router as middleware between your application and the database server to provide RESTful services. MySQL MySQL > > install component install component "file://component_mysql_rest_service" "file://component_mysql_rest_service"; ; MySQL MySQL > > select select * * from from mysql mysql. .component component; ; + +--------------+--------------------+-------------------------------------+ --------------+--------------------+-------------------------------------+ | | component_id component_id | | component_group_id component_group_id | | component_urn component_urn | | + +--------------+--------------------+-------------------------------------+ --------------+--------------------+-------------------------------------+ | | 1 1 | | 1 1 | | file file: ://component_mysql_rest_service | //component_mysql_rest_service | + +--------------+--------------------+-------------------------------------+ --------------+--------------------+-------------------------------------+ 1 1 row row in in set set ( (0.0014 0.0014 sec sec) ) Copyright @ 2025 Oracle and/or its affiliates. 34
  21. Building RESTful APIs with MRS MySQL without SQL Copyright @

    2025 Oracle and/or its affiliates. 35
  22. Our �rst RESTful Endpoint We will create a �rst simple

    RESTful Endpoint that will expose the actor table from the sakila database. We won't use any authentication for this �rst example to keep it simple. Copyright @ 2025 Oracle and/or its affiliates. 36
  23. Our �rst RESTful Endpoint We will create a �rst simple

    RESTful Endpoint that will expose the actor table from the sakila database. We won't use any authentication for this �rst example to keep it simple. We need to create a REST Service �rst. Copyright @ 2025 Oracle and/or its affiliates. 36
  24. Our �rst RESTful Endpoint - testing We can now try

    to browse to our �rst RESTful Endpoint using curl or a browser: h�ps://127.0.0.1:33060/contech/sakila/actor The cerit�cate is self-signed so you need to accept the risk if you use a browser. $ $ curl curl -s -s -k -k https://127.0.0.1:33060/contech/sakila/actor https://127.0.0.1:33060/contech/sakila/actor | | jq jq Copyright @ 2025 Oracle and/or its affiliates. 46
  25. Our �rst RESTful Endpoint - �ltering We can request an

    actor by its primary key like this: Copyright @ 2025 Oracle and/or its affiliates. 48
  26. Our �rst RESTful Endpoint - �ltering (2) Or even �lter

    out on �elds like this: $ $ curl curl -s -s -k -k --get --get 'https://127.0.0.1:33060/contech/sakila/actor/' 'https://127.0.0.1:33060/contech/sakila/actor/' \ \ --data-urlencode --data-urlencode 'q={"firstName":"NICK"}' 'q={"firstName":"NICK"}' | | \ \ jq jq -r -r '.items[] | "\(.actorId)\t\(.firstName)\t\(.lastName)"' '.items[] | "\(.actorId)\t\(.firstName)\t\(.lastName)"' 2 2 NICK WAHLBERG NICK WAHLBERG 44 44 NICK STALLONE NICK STALLONE 166 166 NICK DEGENERES NICK DEGENERES Copyright @ 2025 Oracle and/or its affiliates. 49
  27. Our �rst RESTful Endpoint - �ltering (2) Or even �lter

    out on �elds like this: $ $ curl curl -s -s -k -k --get --get 'https://127.0.0.1:33060/contech/sakila/actor/' 'https://127.0.0.1:33060/contech/sakila/actor/' \ \ --data-urlencode --data-urlencode 'q={"firstName":"NICK"}' 'q={"firstName":"NICK"}' | | \ \ jq jq -r -r '.items[] | "\(.actorId)\t\(.firstName)\t\(.lastName)"' '.items[] | "\(.actorId)\t\(.firstName)\t\(.lastName)"' 2 2 NICK WAHLBERG NICK WAHLBERG 44 44 NICK STALLONE NICK STALLONE 166 166 NICK DEGENERES NICK DEGENERES MySQL MySQL > > select select count count( (* *) ) from from actor actor where where first_name first_name like like 'nick' 'nick'; ; + +----------+ ----------+ | | count count( (* *) ) | | + +----------+ ----------+ | | 3 3 | | + +----------+ ----------+ 1 1 row row in in set set ( (0.0005 0.0005 sec sec) ) Copyright @ 2025 Oracle and/or its affiliates. 49
  28. Building RESTful APIs with MRS MySQL without SQL and without

    GUI Copyright @ 2025 Oracle and/or its affiliates. 50
  29. All in Command Line in SQL We can also create

    our RESTful Endpoint using only SQL in MySQL Shell. This is useful if we want to automate the creation of RESTful Endpoints. We can get all information about the RESTful Endpoints from MySQL Shell in VS Code: Copyright @ 2025 Oracle and/or its affiliates. 51
  30. All in Command Line in SQL (2) CREATE CREATE OR

    OR REPLACE REPLACE REST SERVICE REST SERVICE / /contech PUBLISHED contech PUBLISHED OPTIONS { OPTIONS { "http" "http": { : { "allowedOrigin" "allowedOrigin": : "auto" "auto" } }, , "headers" "headers": { : { "Access-Control-Allow-Headers" "Access-Control-Allow-Headers": : "Content-Type, Authorization, X-Requested-With, Origin, X-Auth-Token" "Content-Type, Authorization, X-Requested-With, Origin, X-Auth-Token", , "Access-Control-Allow-Methods" "Access-Control-Allow-Methods": : "GET, POST, PUT, DELETE, OPTIONS" "GET, POST, PUT, DELETE, OPTIONS", , "Access-Control-Allow-Credentials" "Access-Control-Allow-Credentials": : "true" "true" } }, , "logging" "logging": { : { "request" "request": { : { "body" "body": : true true, , "headers" "headers": : true true } }, , "response" "response": { : { "body" "body": : true true, , "headers" "headers": : true true } }, , "exceptions" "exceptions": : true true } }, , "includeLinksInResults" "includeLinksInResults": : false false, , "returnInternalErrorDetails" "returnInternalErrorDetails": : true true } } Copyright @ 2025 Oracle and/or its affiliates. 52
  31. All in Command Line in SQL (3) ADD ADD AUTH

    APP AUTH APP ` `MRS MRS` ` IF IF EXISTS EXISTS ADD ADD AUTH APP AUTH APP ` `MySQL MySQL` ` IF IF EXISTS EXISTS; ; CREATE CREATE OR OR REPLACE REPLACE REST REST SCHEMA SCHEMA / /sakila sakila ON ON SERVICE SERVICE / /contech contech FROM FROM ` `sakila sakila` ` AUTHENTICATION AUTHENTICATION NOT NOT REQUIRED REQUIRED; ; CREATE CREATE OR OR REPLACE REPLACE REST REST VIEW VIEW / /actor actor ON ON SERVICE SERVICE / /contech contech SCHEMA SCHEMA / /sakila sakila AS AS sakila sakila. .actor CLASS ContechSakilaActor actor CLASS ContechSakilaActor @INSERT @INSERT @UPDATE @UPDATE { { firstName: first_name firstName: first_name, , lastName: last_name lastName: last_name, , actorId: actor_id actorId: actor_id @KEY @KEY @SORTABLE @SORTABLE, , lastUpdate: last_update lastUpdate: last_update } } AUTHENTICATION REQUIRED AUTHENTICATION REQUIRED; ; Copyright @ 2025 Oracle and/or its affiliates. 53
  32. All in Command Line using MySQL Shell In MySQL Shell,

    using the JavaScript or Python mode, get the help of the MRS module: JS JS> > mrs mrs. .help help( () ) Copyright @ 2025 Oracle and/or its affiliates. 57
  33. Modify our RESTful Endpoint We will now modify our RESTful

    Endpoint to return a more complex JSON structure and enable authentication. We will start by editing the REST Object /actor we created before. Copyright @ 2025 Oracle and/or its affiliates. 59
  34. Get the SDK We can see that the SDK has

    been saved in our �le system: $ $ du du -sh -sh contech.mrs.sdk contech.mrs.sdk 124K contech.mrs.sdk 124K contech.mrs.sdk $ tree contech.mrs.sdk/ $ tree contech.mrs.sdk/ contech.mrs.sdk/ contech.mrs.sdk/ ├── contech.py ├── contech.py ├── __init__.py ├── __init__.py ├── mrs_base_classes.py ├── mrs_base_classes.py └── mrs.config.json └── mrs.config.json 1 1 directory, directory, 4 4 files files Copyright @ 2025 Oracle and/or its affiliates. 66
  35. Get the SDK - cmd line It's also possible to

    export the SDK using MySQL Shell command Line without using MySQL Shell for VS Code like this; Copyright @ 2025 Oracle and/or its affiliates. 67
  36. Using the SDK We create a directory for our Python

    code and copy the SDK there: [ [~ ~] ] $ $ mkdir mkdir contech contech [ [~ ~] ] $ $ mv mv contech.mrs.sdk contech/sdk contech.mrs.sdk contech/sdk [ [~ ~] ] $ $ cd cd contech/ contech/ [ [~/contech ~/contech] ] $ $ touch touch contech.py contech.py We can edit our code in the terminal (using Vi) or using VS Code. Copyright @ 2025 Oracle and/or its affiliates. 68
  37. Using the SDK contech.py from from sdk sdk. .contech contech

    import import * * my_service my_service = = Contech Contech( (verify_tls_cert verify_tls_cert= =False False) ) async async def def main main( () ): : await await my_service my_service. .authenticate authenticate( ( username username = = "contech_rest_user" "contech_rest_user", , password password = = "Cont3ch2025!" "Cont3ch2025!", , app app = = "MRS" "MRS", , ) ) records records = = await await my_service my_service. .sakila sakila. .actor actor. .find find( (take take= =10 10) ) for for record record in in records records: : print print( (record record. .first_name first_name + + " " " " + + record record. .last_name last_name) ) asyncio asyncio. .run run( (main main( () )) ) Copyright @ 2025 Oracle and/or its affiliates. 69
  38. Using the SDK - running it $ python3.13 contech.py $

    python3.13 contech.py PENELOPE GUINESS PENELOPE GUINESS NICK WAHLBERG NICK WAHLBERG ED CHASE ED CHASE JENNIFER DAVIS JENNIFER DAVIS JOHNNY LOLLOBRIGIDA JOHNNY LOLLOBRIGIDA BETTE NICHOLSON BETTE NICHOLSON GRACE MOSTEL GRACE MOSTEL MATTHEW JOHANSSON MATTHEW JOHANSSON JOE SWANK JOE SWANK CHRISTIAN GABLE CHRISTIAN GABLE Copyright @ 2025 Oracle and/or its affiliates. 70
  39. Using the SDK - updates We can also try to

    update a record like this: contech_update.py from from sdk sdk. .contech contech import import * * my_service my_service = = Contech Contech( (verify_tls_cert verify_tls_cert= =False False) ) async async def def main main( () ): : await await my_service my_service. .authenticate authenticate( ( username username = = "contech_rest_user" "contech_rest_user", , password password = = "Cont3ch2025!" "Cont3ch2025!", , app app = = "MRS" "MRS", , ) ) records records = = await await my_service my_service. .sakila sakila. .actor actor. .find find( (where where= ={ {"actor_id" "actor_id": : { {"$eq" "$eq": : 4 4} }} }) ) for for record record in in records records: : print print( (record record. .first_name first_name + + " " " " + + record record. .last_name last_name) ) record record. .first_name first_name = = "ANDRA" "ANDRA" await await record record. .update update( () ); ; asyncio asyncio. .run run( (main main( () )) ) Copyright @ 2025 Oracle and/or its affiliates. 71
  40. Using the SDK - updates (2) $ python3.13 contech_update.py $

    python3.13 contech_update.py JENNIFER DAVIS JENNIFER DAVIS Copyright @ 2025 Oracle and/or its affiliates. 72
  41. Using the SDK - updates (2) $ python3.13 contech_update.py $

    python3.13 contech_update.py JENNIFER DAVIS JENNIFER DAVIS $ python3.13 contech.py $ python3.13 contech.py PENELOPE GUINESS PENELOPE GUINESS NICK WAHLBERG NICK WAHLBERG ED CHASE ED CHASE ANDRA DAVIS ANDRA DAVIS JOHNNY LOLLOBRIGIDA JOHNNY LOLLOBRIGIDA BETTE NICHOLSON BETTE NICHOLSON GRACE MOSTEL GRACE MOSTEL MATTHEW JOHANSSON MATTHEW JOHANSSON JOE SWANK JOE SWANK CHRISTIAN GABLE CHRISTIAN GABLE Copyright @ 2025 Oracle and/or its affiliates. 72
  42. Playing with other database objects We can also use the

    SDK to play with other database objects like Views, Stored Procedures and Functions. The full documentation is available at: h�ps://dev.mysql.com/doc/dev/mysql-rest-service/latest/sdk.html Copyright @ 2025 Oracle and/or its affiliates. 73
  43. Using Views Let's use one of the Views available in

    the Sakila database: customer_list Copyright @ 2025 Oracle and/or its affiliates. 74
  44. Using Views Let's use one of the Views available in

    the Sakila database: customer_list Copyright @ 2025 Oracle and/or its affiliates. 74
  45. Using Views Let's use one of the Views available in

    the Sakila database: customer_list Copyright @ 2025 Oracle and/or its affiliates. 74
  46. Using Views (3) Create a Python program to use the

    view and display the name and the county of customers. Don't forget to export again the SDK !! Copyright @ 2025 Oracle and/or its affiliates. 76
  47. Using Views (3) Create a Python program to use the

    view and display the name and the county of customers. Don't forget to export again the SDK !! $ python contech_view.py $ python contech_view.py VERA MCCOY, Afghanistan VERA MCCOY, Afghanistan MARIO CHEATHAM, Algeria MARIO CHEATHAM, Algeria JUDY GRAY, Algeria JUDY GRAY, Algeria JUNE CARROLL, Algeria JUNE CARROLL, Algeria ANTHONY SCHWAB, American Samoa ANTHONY SCHWAB, American Samoa CLAUDE HERZOG, Angola CLAUDE HERZOG, Angola MARTIN BALES, Angola MARTIN BALES, Angola .. ... . Copyright @ 2025 Oracle and/or its affiliates. 76
  48. Using Views (4) contech_view.py from from sdk sdk. .contech contech

    import import * * my_service my_service = = Contech Contech( (verify_tls_cert verify_tls_cert= =False False) ) async async def def main main( () ): : await await my_service my_service. .authenticate authenticate( ( username username = = "contech_rest_user" "contech_rest_user", , password password = = "Cont3ch2025!" "Cont3ch2025!", , app app = = "MRS" "MRS", , ) ) records records = = await await my_service my_service. .sakila sakila. .customer_list customer_list. .find find( () ) for for record record in in records records: : print print( ( record record. .name name + + ", " ", " + + record record. .country country) ) asyncio asyncio. .run run( (main main( () )) ) Copyright @ 2025 Oracle and/or its affiliates. 77
  49. Using Routines Now we will use a function from the

    Sakila database: inventory_in_stock Copyright @ 2025 Oracle and/or its affiliates. 78
  50. Using Routines Now we will use a function from the

    Sakila database: inventory_in_stock Copyright @ 2025 Oracle and/or its affiliates. 78
  51. Using Routines Now we will use a function from the

    Sakila database: inventory_in_stock Copyright @ 2025 Oracle and/or its affiliates. 78
  52. Don't forget to export the SDK at every changes in

    your service! Using the SDK Copyright @ 2025 Oracle and/or its affiliates. 80
  53. Using Routines (3) Now create a Python program to call

    the function and display if the movie with a given id is in stock or not. $ python contech_function.py $ python contech_function.py Movie id? Movie id? 1 1 Movie Movie in in stock stock Movie id? Movie id? 6 6 Movie not Movie not in in stock stock Movie id? Movie id? Copyright @ 2025 Oracle and/or its affiliates. 81
  54. Using Routines (4) contech_function.py from from sdk sdk. .contech contech

    import import * * my_service my_service = = Contech Contech( (verify_tls_cert verify_tls_cert= =False False) ) async async def def main main( () ): : await await my_service my_service. .authenticate authenticate( ( username username = = "contech_rest_user" "contech_rest_user", , password password = = "Cont3ch2025!" "Cont3ch2025!", , app app = = "MRS" "MRS", , ) ) movie_id movie_id = = input input( ("Movie id? " "Movie id? ") ) records records = = await await my_service my_service. .sakila sakila. .inventory_in_stock inventory_in_stock. .call call( (p_inventory_id p_inventory_id= =int int( (movie_id movie_id) )) ) if if records records == == 0 0: : print print( ("Movie not in stock" "Movie not in stock") ) else else: : print print( ("Movie in stock" "Movie in stock") ) while while True True: : asyncio asyncio. .run run( (main main( () )) ) Copyright @ 2025 Oracle and/or its affiliates. 82
  55. Challenge Run the following query: SQL SQL > > update

    update film film set set language_id language_id= =5 5 where where film_id film_id = = round round( (rand rand( () )* *100 100) ); ; Copyright @ 2025 Oracle and/or its affiliates. 83
  56. Challenge Run the following query: SQL SQL > > update

    update film film set set language_id language_id= =5 5 where where film_id film_id = = round round( (rand rand( () )* *100 100) ); ; Create an unauthenticated RESTful Endpoint that will return the list of �lms in a given languageId (5). Copyright @ 2025 Oracle and/or its affiliates. 83
  57. Share your to MySQL #mysql #MySQLCommunity Join our slack channel!

    bit.ly/mysql-slack Copyright @ 2025 Oracle and/or its affiliates. 84