.. include:: /includes.rst.txt .. _scripting_sql: Working with Relational Databases via SQL ========================================= From ADS scripts, the built-in object `SQL` can be used to connect to relational databases through SQL. This may be used to implement batch importers or update scripts. Two functions are provided right now * `SQL.query` for :ref:`scripting_sql_query` * `SQL.update` for :ref:`scripting_sql_update` .. _scripting_sql_query: Querying SQL Databases from ADS ------------------------------- The following example walks through all rows of the table called `country` in the database called `world` and creates one instance of the RDFS class `g:Country` for each, based on the values of the `Code` and `Name` columns. .. literalinclude:: _code/_sql/sql_query_example.js :linenos: :language: js .. _scripting_sql_update: Updating SQL Databases with ADS ------------------------------- The following example shows the syntax of SQL update commands. As usual, you may want to use JavaScript string substitution to produce a suitable SQL string from your data. .. literalinclude:: _code/_sql/sql_update_example.js :linenos: :language: js