Skip to content
Trevor DeVore edited this page Nov 30, 2018 · 9 revisions

SQL Yoga

Database library for LiveCode

SQL Yoga is a database library for LiveCode built on top of RevDB or Valentina. Using the database schema and information from you, the developer, SQL Yoga allows you to write less code when querying and updating an application's database. It also provides additional callbacks and opportunities to validate the data.

While the library can be used independently of any framework, SQL Yoga is distributed as a Helper for the Levure framework. Levure makes using SQL Yoga much easier from a configuration and customization perspective.

SQL Yoga works with LiveCode 8 or newer.

SQL Yoga Features

Here are examples of some of the features in SQL Yoga.

Generate queries by creating and setting properties on SQL Query objects or SQL Record objects.

put sqlquery_createObject("news_releases") into tQueryA
sqlquery_set tQueryA, "sort by", "published_date"
sqlquery_retrieveAsData tQueryA, tNewsReleases

Easily update records.

put 2 into tRecId
put true into tTaskA["complete"]
sqlquery_update "task", tRecId, tTaskA

Chain together predefined search conditions using scope obects.

put sqlquery_createObject("todo_items") into tQueryA
sqlquery_addScope tQueryA, "not complete"
sqlquery_addScope tQueryA, "name contains", \
          sqlyoga_splitUserSearchString(the text of field "Search")
sqlquery_retrieveAsArray tQueryA, tFilteredToDosA

Leverage relationships between tables.

put sqlquery_createObject("todo_items") into tQueryA
sqlquery_set tQueryA, "related table joins", "people"
sqlquery_retrieveAsArray tQueryA, tToDosWithAssignedPeopleA

Example Application

For an example of a Levure application that uses SQL Yoga check out the sql-yoga-levure repository.

Learning to use SQL Yoga

Get up and running with an existing database

  1. Add the SQL Yoga helper to an existing Levure application
  2. Import the existing database schema into the databse schema YAML file
  3. Update the database schema YAML file whenever you update your database schema

Get up and running when creating your database using SQL Yoga

  1. Add the SQL Yoga helper to an existing Levure application
  2. Create and run a migration file using YAML to describe your database
  3. Create additional migration files as needed

What's next?

  1. Read about error handling
  2. Connect to your database
  3. Start querying your database using SQL Query objects and SQL Record objects
  4. Review the rest of the documentation to learn about all of the possibilites.