<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Database Applications &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/database-applications/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Wed, 07 May 2025 14:28:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Year of Code 2025: February Project, Database Apps</title>
		<link>https://blog.xojo.com/2025/02/11/year-of-code-2025-february-project/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Tue, 11 Feb 2025 16:48:26 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Year of Code]]></category>
		<category><![CDATA[#YearofCode]]></category>
		<category><![CDATA[Beginner Tips]]></category>
		<category><![CDATA[Database Applications]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=14441</guid>

					<description><![CDATA[February&#8217;s&#160;Year of Code 2025&#160;topic is Databases and my project is a SQLite object-relation mapping library that I call Storm. I first created Storm in 2008&#8230;]]></description>
										<content:encoded><![CDATA[
<p>February&#8217;s&nbsp;<a href="https://blog.xojo.com/2025/01/09/year-of-code-2025-kickoff/" target="_blank" rel="noreferrer noopener">Year of Code 2025</a>&nbsp;topic is Databases and my project is a SQLite object-relation mapping library that I call Storm.</p>



<p>I first created Storm in 2008 when I was working on consulting projects as a way to more rapidly create database apps for clients. It has been updated over the years and the latest version is available on GitHub:</p>



<p><a href="https://github.com/paullefebvre/storm">Storm</a></p>



<p>An ORM lets you write code like this to set database column values and save them:</p>



<pre class="wp-block-code"><code>Var dodgers As New Team
dodgers.Name = "LA Dodgers"
dodgers.Coach = "Dave Roberts"
dodgers.Save</code></pre>



<p>Team is a table in the database with a corresponding class in Xojo that inherits from Storm.DBObject.</p>



<p>The included demo projects shows how you can implement a simple UI for a database with Team and Player tables.</p>



<figure class="wp-block-image size-large is-resized"><img fetchpriority="high" decoding="async" width="1024" height="851" src="https://blog.xojo.com/wp-content/uploads/2025/02/CleanShot-2025-02-04-at-16.45.54@2x-1024x851.png" alt="" class="wp-image-14445" style="width:550px;height:auto" srcset="https://blog.xojo.com/wp-content/uploads/2025/02/CleanShot-2025-02-04-at-16.45.54@2x-1024x851.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/02/CleanShot-2025-02-04-at-16.45.54@2x-300x249.png 300w, https://blog.xojo.com/wp-content/uploads/2025/02/CleanShot-2025-02-04-at-16.45.54@2x-768x639.png 768w, https://blog.xojo.com/wp-content/uploads/2025/02/CleanShot-2025-02-04-at-16.45.54@2x.png 1424w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>The docs for Storm are contained within its <a href="https://github.com/paullefebvre/storm/wiki">Github repository wiki</a>.</p>



<p>In addition to accessing the full repository on GitHub, you can also download <a href="https://github.com/paullefebvre/storm/archive/refs/tags/v1.2.1.zip">Storm as a ZIP</a>.</p>



<p>I’ve created a&nbsp;<a href="https://forum.xojo.com/t/2025-year-of-code-february/84239">forum topic</a>&nbsp;for you to start sharing your Year of Code projects and I’ll also be sure to include this one as well. Remember, <a href="https://blog.xojo.com/2025/01/09/year-of-code-2025-kickoff/">participants can win a $100</a> to use in the Xojo Store!</p>



<p><em>Paul learned to program in BASIC at age 13 and has programmed in more languages than he remembers, with Xojo being an obvious favorite. When not working on Xojo, you can find him talking about retrocomputing at <a href="https://goto10.substack.com" target="_blank" rel="noreferrer noopener">Goto 10</a> and </em>on Mastodon @lefebvre@hachyderm.io.</p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>



<p><strong>Year of Code Project</strong></p>



<ul class="wp-block-list">
<li><a href="https://blog.xojo.com/2025/01/09/year-of-code-2025-kickoff/">Year of Code: Kickoff</a></li>



<li><a href="https://blog.xojo.com/2025/01/15/year-of-code-2025-january-project/" target="_blank" rel="noreferrer noopener">January Project: Desktop Apps</a>&nbsp;|&nbsp;<a href="https://forum.xojo.com/t/year-of-code-2025-january-project-sharing/83927" target="_blank" rel="noreferrer noopener">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/02/11/year-of-code-2025-february-project/">February Project: Database Apps</a>&nbsp;|&nbsp;<a href="https://forum.xojo.com/t/2025-year-of-code-february" target="_blank" rel="noreferrer noopener">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/03/05/year-of-code-2025-march-project-web-apps/">March Project: Web Apps</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-march/84474?u=alyssa_foley">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/04/08/year-of-code-2025-april-project-user-interface/">April Project: User Interface</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-april-user-interface/84926">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/05/07/year-of-code-2025-may-project-mobile-apps/">May Project: Mobile Apps</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-may-is-mobile/85272">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/06/10/year-of-code-2025-june-project-cross-platform-code-class/">June Project: Code Sharing</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-june-is-code-sharing/85612">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/07/10/year-of-code-2025-july-project-charting/">July Project: Charting</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-july-is-charting/85896">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/08/07/year-of-code-2025-august-project-console-apps/">August Project: Console Apps</a> | <a href="https://forum.xojo.com/t/august-2025-year-of-code-console-apps/86203">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/09/08/year-of-code-2025-september-project-games/">September Project: Games</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-septgamer">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/10/13/year-of-code-2025-october-project-multi-platform-communication/">October Project: Multi-Platform</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-october-multi-platform-communication/86717">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/11/10/year-of-code-2025-november-project-pdf-postcard-generator/">November Project: PDF</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-november-pdf/86969">Forum Discussion</a></li>
</ul>



<p><strong>How to Play:</strong></p>



<p>Each month we&#8217;ll announce a new theme and share an example project of our own. Share your projects to the Xojo Forum thread for that month via GitHub (all the links you need are posted above ↑ ). Learn how to use <a href="https://blog.xojo.com/2024/04/02/using-xojo-and-github/">Xojo and GitHub</a>.</p>



<p><strong>The Prizes:</strong></p>



<p>Monthly winners get $100 at the Xojo store. Every month you submit a project is another chance to win the grand prize. The grand prize is $250 cash plus a Xojo Pro license and a year of GraffitiSuite and will be announce in December. Learn more about the <a href="https://blog.xojo.com/2025/01/09/year-of-code-2025-kickoff/#prizes">prizes</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQLite 3.45.1</title>
		<link>https://blog.xojo.com/2024/03/26/sqlite-3-45-1/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Tue, 26 Mar 2024 15:27:31 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[2024r1]]></category>
		<category><![CDATA[Database Applications]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=12700</guid>

					<description><![CDATA[Xojo 2024 Release 1 includes an updated version of SQLite for your Desktop, Web, Console and iOS apps. We have upgraded the library from 3.39.4 (which is from 2022-09-29) to 3.45.1 (released 2024-01-30). Here are a few of the improvements.]]></description>
										<content:encoded><![CDATA[
<p>Xojo 2024 Release 1 includes an updated version of SQLite for your Desktop, Web, Console and iOS apps. We have upgraded the library from 3.39.4 (which is from 2022-09-29) to 3.45.1 (released 2024-01-30). Here are a few of the improvements.</p>



<h2 class="wp-block-heading">Functions</h2>



<p>There are a few new SQLite functions that can now be used in your SQL statements.</p>



<p><strong>concat()</strong></p>



<p>The <a href="https://www.sqlite.org/lang_corefunc.html#concat">concat()</a> function takes an arbitrary number of string parameters and concatenates them all together. Previous versions of SQLite required you to instead use the concat operator, this is the double-pipe: ||. Concat() is a standard function on many other databases (PostgreSQL, MySQL and SQL Server) so it is nice to finally see it available on SQLite as it allow more consistent SQL code.</p>



<p>Using the Chinook sample database, this SQL concatenates the Name and Composer columns from the Track table:</p>



<pre class="wp-block-code"><code>SELECT concat(Name, ‘ by ‘, Composer) FROM Track</code></pre>



<p>Here is the output:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="652" src="https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-1024x652.png" alt="" class="wp-image-12701" srcset="https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-1024x652.png 1024w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-300x191.png 300w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-768x489.png 768w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-1536x978.png 1536w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-2048x1304.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>concat_ws()</strong></p>



<p>The <a href="https://www.sqlite.org/lang_corefunc.html#concat_ws">concat_ws()</a> method is <strong>concat</strong> but <strong>w</strong>ith a <strong>s</strong>eparator. Strange naming aside, it works the same except that the first parameter is used a separator that is inserted between each string. This SQL separates the Name, Composer and Milliseconds with &#8220;&#8212;&#8220;:</p>



<pre class="wp-block-code"><code>SELECT concat_ws(‘---‘, Name, Composer, Milliseconds) FROM Track</code></pre>



<p>Here is the output:</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="652" src="https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-1-1024x652.png" alt="" class="wp-image-12702" srcset="https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-1-1024x652.png 1024w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-1-300x191.png 300w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-1-768x489.png 768w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-1-1536x978.png 1536w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-1-2048x1304.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>timediff()</strong></p>



<p>The <a href="https://www.sqlite.org/lang_datefunc.html#tmdif">timediff()</a> function calculates the elapsed time between two dates and returns the result in a human-readable format.</p>



<p>This SQL displays the time difference between Dec 12, 2023 and March 26, 2024:</p>



<pre class="wp-block-code"><code>SELECT timediff('2023-12-12','2024-03-26')</code></pre>



<p>Here is the output of 3 months and 14 days (note that it is negative because the earlier date is first in the parameter list):</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="652" src="https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-2-1024x652.png" alt="" class="wp-image-12703" srcset="https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-2-1024x652.png 1024w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-2-300x191.png 300w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-2-768x489.png 768w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-2-1536x978.png 1536w, https://blog.xojo.com/wp-content/uploads/2024/03/Pasted-Graphic-2-2048x1304.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">Other Changes</h2>



<p>Overall I didn&#8217;t notice many other other significant new features. However, many bugs have been fixed, especially around  database integrity checks and the somewhat <a href="https://blog.xojo.com/2022/12/13/sqlite-new-features-in-xojo-2022r4">new JSON support</a>.</p>



<p>You can find the full list of SQLite changes on their <a href="https://www.sqlite.org/changes.html">Release History page</a>.</p>



<p><em>Paul learned to program in BASIC at age 13 and has programmed in more languages than he remembers, with Xojo being an obvious favorite. When not working on Xojo, you can find him talking about retrocomputing at <a href="https://goto10.substack.com" target="_blank" rel="noreferrer noopener">Goto 10</a> and </em>on Mastodon @lefebvre@hachyderm.io.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Develop Database Apps with Xojo</title>
		<link>https://blog.xojo.com/2023/09/26/develop-database-apps-with-xojo/</link>
		
		<dc:creator><![CDATA[Xojo]]></dc:creator>
		<pubDate>Tue, 26 Sep 2023 18:06:00 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Beginner Tips]]></category>
		<category><![CDATA[Database Applications]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Rapid Application Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Xojo API 2.0]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=9320</guid>

					<description><![CDATA[After you have designed your interface and begun coding, your next step may be to connect to a database. This blog post tells you the databases supported by Xojo, shows you where to find code samples and examples, plus tutorials and videos that walk you through connecting, updating, querying and managing database, plus, an introduction to Xojo's new DBKit. Get the resources and knowledge you need to get your first database project off the ground today.]]></description>
										<content:encoded><![CDATA[
<p>After you have designed your interface and begun coding, your next step may be to connect to a database. This blog post tells you the databases supported by Xojo, shows you where to find code samples and examples, plus tutorials and videos that walk you through connecting, updating, querying and managing a database, plus, an introduction to Xojo&#8217;s new DBKit. Get the resources and knowledge you need to get your first database project off the ground today.</p>



<span id="more-9320"></span>



<h3 class="wp-block-heading">Database Support</h3>



<p>Xojo works with a wide variety of databases. SQLite is bundled with your Xojo license and is a great beginner database for desktop, web and mobile apps. Xojo includes direct support for SQLite, PostgreSQL and MySQL. Plus, you can use <a href="https://documentation.xojo.com/topics/databases/supported_engines/odbc.html#odbc">ODBC</a> to connect to just about anything else, such as Oracle, MS-SQL Server, Microsoft Access, Firebird or even IBM iSeries.</p>



<h3 class="wp-block-heading">Examples</h3>



<p>To help you get started, there are many examples in the Examples/Databases folder included with the Xojo <a href="https://xojo.com/download/">Download</a>, including examples that connect to each of the supported databases. You can find a <a href="https://documentation.xojo.com/resources/examples.html">breakdown of the examples</a> included in the Examples folder in the Xojo Programming Language Documentation.</p>



<p><a href="http://www.xojo.com/blog/en/assets_c/2014/07/DBExamples-429.php"></a>Additionally, you can check out the <a href="https://demos.xojo.com/#customerID">Eddie’s Electronics</a> sample app (located in Examples/Sample Applications/EddiesElectronics) to see how to share database code between Xojo desktop and Xojo web apps.</p>



<p>DBKit is an example project designed to make it easier to build desktop and web applications that are front-ends to databases. Specifically, DBKit makes it easy to connect a database table to the user interface controls on a layout. DBKit also handles a lot of the interface for you.&nbsp;You can read more about <a href="https://documentation.xojo.com/topics/databases/dbkit.html">DBKit</a> in the Xojo Documentation.</p>



<h3 class="wp-block-heading">Read: Documentation</h3>



<p>After you have reviewed the examples, the <a href="https://documentation.xojo.com/topics/databases/database_basics_for_beginners.html">Database Overview</a> in the Xojo Documentation will help with next steps. Remember, Xojo comes bundled with SQLite which is an excellent database for desktop, web and mobile apps. Read more about using <a href="https://documentation.xojo.com/topics/databases/supported_engines/sqlite/overview.html">SQLite</a> in the Xojo Documentation and check out this <a href="https://documentation.xojo.com/topics/databases/supported_engines/sqlite/sqlite_basics.html">SQLite Tutorial</a> for more detail.</p>



<h3 class="wp-block-heading">Watch: Videos</h3>



<p>The Xojo YouTube channel has hundreds of videos on all things Xojo. Here are the most recent Xojo Database videos and playlists:</p>



<ul class="wp-block-list">
<li>Video: <a href="https://youtu.be/GGyu4D0ni28">Connecting to a Database from Xojo</a></li>



<li>Video: <a href="https://youtu.be/JWja37wXz2U">Updating a Database from Xojo</a></li>



<li>Video: <a href="https://youtu.be/8ENtgkzvyS0">Querying a Database from Xojo</a></li>



<li>Video: <a href="https://youtu.be/wVHYk-4XG2o">Managing the UI when Updating a Database</a></li>



<li>Video: <a href="https://youtu.be/3Jjf1Xrnm2w">Using DBKit to easily connect databases to Xojo applications</a></li>



<li>Playlist: <a href="https://www.youtube.com/playlist?list=PLPoq910Q9jXhRoPw0_mHKdVUKPXpL9TKV">Using Databases with Xojo</a> &#8211; A growing, catch-all playlist for videos related to Xojo and databases.</li>



<li>Playlist: <a href="https://www.youtube.com/playlist?list=PLPoq910Q9jXjDBrL3KymUwnagM8d7Xbia">Xojo and SQLite</a> &#8211; SQLite comes bundled with Xojo and is a great database for beginners building desktop, web and mobile apps with Xojo.</li>
</ul>



<h3 class="wp-block-heading">Vendor Documentation</h3>



<p>Lastly, you should always refer to the vendor-specific documentation for the database you are using to learn the specifics about how that database works, including SQL syntax.</p>



<ul class="wp-block-list">
<li><a href="http://www.sqlite.org/docs.html">SQLite</a></li>



<li><a href="http://www.postgresql.org/docs/">PostgreSQL</a></li>



<li><a href="http://dev.mysql.com/doc/">MySQL</a></li>



<li><a href="http://www.oracle.com/technetwork/indexes/documentation/index.html?ssSourceSiteId=ocomen">Oracle Database</a></li>



<li><a href="http://msdn.microsoft.com/en-us/library/bb545450.aspx">Microsoft SQL Server</a></li>
</ul>



<p>Xojo simplifies the development process, reduces complexity and empowers developers to create efficient and functional database applications with relative ease. The Xojo IDE is free to use for development and testing &#8211; design, develop, run and debug your app all without a license. Purchase a license when you are ready to compile your apps, licenses start at $149. Visit the <a href="https://xojo.com/store/">Xojo Store</a> to find the license right for your project.</p>



<p>If you have questions after you have reviewed these materials, the Xojo <a href="https://forum.xojo.com">Forum</a> is an accessible and essential resource for Xojo users of all levels. You can also <a href="https://www.xojo.com/company/contact.php">contact</a> Xojo directly with your questions.</p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQLite 3.39.4: New Features</title>
		<link>https://blog.xojo.com/2022/12/13/sqlite-new-features-in-xojo-2022r4/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Tue, 13 Dec 2022 14:32:00 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Database Applications]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLite]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=11053</guid>

					<description><![CDATA[In Xojo 2022r4, we have updated our SQLite library to SQLite v3.39.4. I thought I'd highlight a few notable upgrades including: STRICT tables
PRAGMA table_list
RIGHT and FULL OUTER JOIN
Built-in JSON support]]></description>
										<content:encoded><![CDATA[
<p>In Xojo 2022r4, we have updated our SQLite library to SQLite v3.39.4. Previously Xojo was using 3.36.0, and since there have been <a href="https://www.sqlite.org/changes.html">quite a few SQLite updates since then</a> I thought I&#8217;d highlight a few notable features:</p>



<ul class="wp-block-list"><li>STRICT tables</li><li>PRAGMA table_list</li><li>RIGHT and FULL OUTER JOIN</li><li>Built-in JSON support</li></ul>



<p>More about each of these below.</p>



<h2 class="wp-block-heading">STRICT Tables</h2>



<p>One of SQLite&#8217;s most unusual capabilities is that it does not care about what data goes into a column. Although you could specify a type for a column, it was really more of a suggestion as other types of data could be put into the column. This behavior is different than most other relational databases and can sometimes be a source of confusion.</p>



<p>Now you can create your tables using the <a href="https://www.sqlite.org/stricttables.html">STRICT keyword</a> to force them to require column types and to force the column types to always be checked when putting data into them.</p>



<p>You are still limited to INT, INTEGER, REAL, TEXT and BLOB. That means there is still no DATE or DATETIME type like you might find in other databases. Instead use TEXT with YYYY-MM-DD format.</p>



<p>However, an ANY type was added which essentially allows you to clearly state that the column can contain anything. This allows you to have a mixture of specific types and generic types in your STRICT tables.</p>



<p>Note that the STRICT keyword goes at the end of the CREATE TABLE command:</p>



<pre class="wp-block-preformatted">CREATE TABLE Team (ID INTEGER, Name TEXT, Coach TEXT, City TEXT, PRIMARY KEY(ID)) STRICT;</pre>



<p>The <a href="https://www.sqlite.org/stricttables.html">SQLite docs</a> have more information about the new STRICT table feature.</p>



<h2 class="wp-block-heading">PRAGMA table_list</h2>



<p>With Xojo you could always get the list of tables by using the <a href="https://documentation.xojo.com/api/databases/database.html#database-tables">Database.Tables()</a> method. However if you wanted to get the list of table using SQL you had to directly query the sqlite_master table.</p>



<p>Now there is a simple PRAGMA that can do the same thing:</p>



<pre class="wp-block-code"><code>PRAGMA table_list</code></pre>



<p>It returns a list of tables and some other details about the table (which may change over time <a href="https://www.sqlite.org/pragma.html#pragma_table_list">according to the SQLite docs</a>).</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-10.16.02@2x-1024x852.png" alt="" class="wp-image-11057" width="625" height="520" srcset="https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-10.16.02@2x-1024x852.png 1024w, https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-10.16.02@2x-300x250.png 300w, https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-10.16.02@2x-768x639.png 768w, https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-10.16.02@2x.png 1144w" sizes="auto, (max-width: 625px) 100vw, 625px" /></figure>



<h2 class="wp-block-heading">RIGHT and FULL OUTER JOIN</h2>



<p>Joining tables is a common task with SQL. The most common type of join is an INNER JOIN where only the rows common to both tables are included in the result. Other less common types of joins include LEFT OUTER, RIGHT OUTER and FULL OUTER (sometimes OUTER is omitted when referring to these types of joins).</p>



<p>SQLite has had support for LEFT OUTER joins for a long time, but support for RIGHT OUTER and FULL OUTER were missing. But now they are here, giving your more complicated queries better compatibly with the &#8220;big name&#8221; databases.</p>



<p>Learn more about these types of joins at <a href="https://www.w3schools.com/sql/sql_join.asp">W3 schools</a>.</p>



<h2 class="wp-block-heading">JSON Support</h2>



<p>I&#8217;ve saved the big one for last: your SQL databases can now work with JSON data within columns.</p>



<p>Here is a sample table to work with with some JSON data that is stored in the players column:</p>



<pre class="wp-block-preformatted">CREATE TABLE team(id INTEGER PRIMARY KEY, Name TEXT, players TEXT);</pre>



<pre class="wp-block-preformatted">INSERT INTO TEAM VALUES (NULL, 'Seagulls', '[ {"Name":"Bob","position":"1B"}, {"Name":"Tom","position":"2B"} ]')</pre>



<pre class="wp-block-preformatted">INSERT INTO TEAM VALUES (NULL, 'Pigeons', '[ {"Name":"Bill","position":"1B"}, {"Name":"Tim","position":"2B"} ]')</pre>



<pre class="wp-block-preformatted">INSERT INTO TEAM VALUES (NULL, 'Crows', '[ {"Name":"Betty","position":"1B"}, {"Name":"Tina","position":"2B"} ]')</pre>



<p>Let&#8217;s say you want to get the first player on each team. Without SQLite JSON support you would have to pull out the JSON column data and parse it out separately. But now you can do it with this SQL like this:</p>



<pre class="wp-block-preformatted">SELECT players -&gt; 0 FROM team</pre>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="590" height="568" src="https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-10.54.09@2x.png" alt="" class="wp-image-11063" srcset="https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-10.54.09@2x.png 590w, https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-10.54.09@2x-300x289.png 300w" sizes="auto, (max-width: 590px) 100vw, 590px" /></figure>



<p>The above SQL says: for each row fetch the first array element from the JSON data in players.</p>



<p>This is how you would list all the players on all the teams:</p>



<pre class="wp-block-preformatted">SELECT team.Name, json_each.value -&gt; 'Name' FROM team, json_each(team.players)</pre>



<p>And if you want to get the actual value without the quotes, you can use the -&gt;&gt; operator (and also rename the result):</p>



<pre class="wp-block-preformatted">SELECT team.Name, json_each.value -&gt;&gt; 'Name' As PlayerName FROM team, json_each(team.players)</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="544" src="https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-11.40.49@2x-1024x544.png" alt="" class="wp-image-11075" srcset="https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-11.40.49@2x-1024x544.png 1024w, https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-11.40.49@2x-300x159.png 300w, https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-11.40.49@2x-768x408.png 768w, https://blog.xojo.com/wp-content/uploads/2022/12/CleanShot-2022-12-12-at-11.40.49@2x.png 1250w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>The SQLite JSON support can do much, much more which you can read about on the <a href="https://www.sqlite.org/json1.html">SQLite JSON doc page</a>.</p>



<p><em>Paul learned to program in BASIC at age 13 and has programmed in more languages than he remembers, with Xojo being an obvious favorite. When not working on Xojo, you can find him talking about retrocomputing at <a href="https://goto10.substack.com" target="_blank" rel="noreferrer noopener">Goto 10</a> and </em>on Mastodon @lefebvre@hachyderm.io.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>SQLite 3.36.0 New Features</title>
		<link>https://blog.xojo.com/2021/11/18/sqlite-new-features/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Thu, 18 Nov 2021 14:00:00 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Database Applications]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=9581</guid>

					<description><![CDATA[Xojo 2021 Release 3 includes SQLite 3.36.0, which has a few new features, such as: RETURNING on DELETE, INSERT and UPDATE commands
ALTER TABLE DROP COLUMN
EXPLAIN QUERY PLAN]]></description>
										<content:encoded><![CDATA[
<p>Xojo 2021 Release 3 includes <a href="https://www.sqlite.org/changes.html">SQLite 3.36.0</a>, which has a few new features, such as:</p>



<ul class="wp-block-list"><li>RETURNING on DELETE, INSERT and UPDATE commands</li><li>ALTER TABLE DROP COLUMN</li><li>EXPLAIN QUERY PLAN</li></ul>



<h2 class="wp-block-heading">RETURNING Clause</h2>



<p>The <a href="https://www.google.com/search?client=safari&amp;rls=en&amp;q=sqlite+returning+clause&amp;ie=UTF-8&amp;oe=UTF-8">RETURNING clause</a> can be used on DELETE, INSERT and UPDATE commands to get a value back after the command has run without having to do a separate query.</p>



<p>For example, you could send an UPDATE command that recalculates a value and have it return the new value like this:</p>



<pre class="wp-block-preformatted">UPDATE sales SET amount = amount * 2 WHERE ID = 1 RETURNING amount</pre>



<p>This would now return the newly calculated amount, where as you would previously have to issue a separate SELECT statement to get the amount.</p>



<p>This example would append &#8221; the Great&#8221; to the end of all names in the Artist table and return the new name along with the ID:</p>



<pre class="wp-block-preformatted">UPDATE Artist SET Name = Name || + " the Great" RETURNING Name, ArtistId</pre>



<p>To access the RETURNING value from Xojo, you&#8217;ll want to send the command using <a href="https://documentation.xojo.com/api/databases/database.html#database-selectsql">SelectSQL</a> instead of <a href="https://documentation.xojo.com/api/databases/database.html#database-executesql">ExecuteSQL</a> so that you can use a <a href="https://documentation.xojo.com/api/databases/rowset.html">RowSet</a> to get the values.</p>



<h2 class="wp-block-heading">DROP Column</h2>



<p>SQLite has historically been pretty inflexible when it comes to modify a table&#8217;s structure after it has been created. Until recently you could only rename a table and add new columns to it. Back in <a href="https://blog.xojo.com/2018/12/18/sqlite-3-25-adds-window-functions-and-improves-alter-table/">SQLite 3.25</a>, the ability to rename existing columns on a table was added. And now you can also <a href="https://www.sqlite.org/lang_altertable.html">remove (drop) columns</a> from a table.</p>



<p>You can do this using the standard syntax like this:</p>



<pre class="wp-block-preformatted">ALTER TABLE MyTable DROP COLUMN OldColumn;</pre>



<h2 class="wp-block-heading">Query Plan</h2>



<p>A query plan describes how SQLite processes your SQL query. It is really only useful for debugging purposes. If you have a slow-running query it can sometimes be useful to look at the query plan to see if it is pointing out an obvious problem with the query, which might be that the query is doing a table scan rather than using an index.</p>



<p>To see a query plan, you put <a href="https://www.sqlite.org/eqp.html">EXPLAIN QUERY PLAN</a> in front of the SQL query. This features has been in SQLite for a long time, but it has recently gotten some output improvements that might make it easier to use. Be sure to give it a try.</p>



<p>As an example, here is how to get the query plan for a simple query using the AlbumArtist view in the Chinook database:</p>



<p>EXPLAIN QUERY PLAN SELECT * FROM AlbumArtist</p>



<p>The query plan looks like this, with separate rows returned for each evaluation:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="662" height="282" src="https://blog.xojo.com/wp-content/uploads/2021/11/CleanShot-2021-11-10-at-10.05.51.png" alt="" class="wp-image-9585" srcset="https://blog.xojo.com/wp-content/uploads/2021/11/CleanShot-2021-11-10-at-10.05.51.png 662w, https://blog.xojo.com/wp-content/uploads/2021/11/CleanShot-2021-11-10-at-10.05.51-300x128.png 300w" sizes="auto, (max-width: 662px) 100vw, 662px" /></figure>



<p>To learn more about using SQLite with Xojo, check out these additional resources: Xojo SQLite Database <a href="https://documentation.xojo.com/api/databases/sqlitedatabase.html">Documentation</a>, <a href="https://documentation.xojo.com/topics/databases/supported_engines/sqlite/sqlite_basics.html">Tutorial</a>: SQLite Basics, <a href="https://blog.xojo.com/2021/10/28/3-steps-to-seamlessly-deploy-sqlite-projects-on-desktop-web-ios-2/">Blog Post</a>: 3 Steps to Seamlessly Deploy SQLite Projects on Desktop, Web &amp; iOS and <a href="https://blog.xojo.com/2021/03/09/backwards-sqlite-backups/">Blog Post</a>: Backwards SQLite Backups.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>3 Steps to Seamlessly Deploy SQLite Projects on Desktop, Web &#038; iOS</title>
		<link>https://blog.xojo.com/2021/10/28/3-steps-to-seamlessly-deploy-sqlite-projects-on-desktop-web-ios-2/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Thu, 28 Oct 2021 15:21:56 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Database Applications]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=9363</guid>

					<description><![CDATA[This tutorial will show you how to deploy your SQLite based projects so they behave right on Desktop, Web and iOS, copying the database file to the right place on every target.]]></description>
										<content:encoded><![CDATA[
<p>This tutorial will show you how to deploy SQLite based projects on Desktop, Web and iOS, copying the SQLite database file to the right place on every target.</p>



<h2 class="wp-block-heading">1. Adding the Database File</h2>



<p>You probably created your SQLite database file using an external editor; so first add that file to your Xojo project. You can do that in several ways, but usually it&#8217;s best to add a Build Step. This way, the file will be automatically added to the folder every time you compile your app. <em>Bonus: Doing this allows you to decide to use different paths when debugging or deploying your app.</em></p>



<p>Adding a Build Step in Xojo is the same for <strong>Desktop</strong> and <strong>Web</strong> projects. Select the target in the Build Settings then&nbsp;from the contextual menu choose the &#8220;Add to Build Settings &gt; Build Step &gt; Copy Files&#8221; option.</p>


<div class="wp-block-image is-style-default">
<figure class="aligncenter"><img loading="lazy" decoding="async" width="1024" height="297" src="https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileDesktop-1024x297.png" alt="" class="wp-image-9364" srcset="https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileDesktop-1024x297.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileDesktop-300x87.png 300w, https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileDesktop-768x222.png 768w, https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileDesktop.png 1084w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>This gives you access to the Inspector Panel for the just-added item where you can enter a name for the Build Step, choose if the copy file action will be executed both for debugging or deployment and, most importantly, choose the location where the file should be copied when the app compiles.</p>



<p>The Destination menu contains a number of typical paths (or most relevant folders). For example, a good destination option would be &#8220;Resources Folder&#8221;. Don&#8217;t forget to add the database file itself using the buttons on the Build Editor toolbar.</p>


<div class="wp-block-image is-style-default">
<figure class="aligncenter"><img loading="lazy" decoding="async" width="662" height="432" src="https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileInspector.png" alt="" class="wp-image-9365" srcset="https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileInspector.png 662w, https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileInspector-300x196.png 300w" sizes="auto, (max-width: 662px) 100vw, 662px" /></figure>
</div>


<p>On <strong>iOS</strong>, adding a Build Step is nearly the same as for Desktop and Web. The only difference is that you have to choose the icon with an iPhone picture in it in order to access the Build Step contextual menu&gt; In addition to that, every added resource needs to be signed with a certificate.</p>


<div class="wp-block-image is-style-default">
<figure class="aligncenter"><img loading="lazy" decoding="async" width="1024" height="253" src="https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileiOS-1024x253.png" alt="" class="wp-image-9366" srcset="https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileiOS-1024x253.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileiOS-300x74.png 300w, https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileiOS-768x190.png 768w, https://blog.xojo.com/wp-content/uploads/2021/09/CopyFileiOS.png 1124w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<h2 class="wp-block-heading">2. Copying the Database File to a &#8220;Working&#8221; Folder</h2>



<p>You may think that adding a Build Step is all you need to do, because if the database file is already copied to a well known path then you only need to provide that path as the DatabaseFile property on a new SQLiteDatabase instance. But this is not the case.</p>



<p>They are many reasons you shouldn&#8217;t do that, notably because the database would be open in read/write mode and if you write to that database file inside an application bundle, then you&#8217;d be modifying a resource and that would invalidate any certificate signature on your app.</p>



<p>The best thing to do is to check every time you run the app to see if the database file has already been copied from the app bundle (or folder) into a target folder that doesn&#8217;t have an access problem when it is time to use the database. The Application Support folder is a good place for <strong>Desktop</strong> apps, while the Documents folder is fine for <strong>Web</strong> and <strong>iOS</strong> apps.</p>



<p>For example, if our database file is named &#8220;EddiesElectronics.sqlite&#8221; and our app name is &#8220;Xojotest&#8221;, then we can add the following code fragment into the Opening Event Handler of a <strong>Desktop</strong> app. Also, make sure to add the pDatabase property to the App object in the Navigator:</p>



<pre class="wp-block-code"><code>Var source As FolderItem = SpecialFolder.Resource("EddiesElectronics.sqlite")
Var name As String = app.ExecutableFile.name.NthField(".", 1)

// Check if there is a folder with the App name in special Application Data
// if not, create it and copy the database file from Resources bundle/directory
If Not (SpecialFolder.ApplicationData.Child(name).Exists And SpecialFolder.ApplicationData.Child(name).IsFolder) Then SpecialFolder.ApplicationData.Child(name).CreateFolder

If Not SpecialFolder.ApplicationData.child(name).child(source.name).exists Then source.CopyTo(SpecialFolder.ApplicationData.Child(name))

Try
  // Create a SQLiteDatabase instance and try to open our database file from
  // the path
  pDatabase = New SQLiteDatabase
  pDatabase.DatabaseFile = SpecialFolder.ApplicationData.Child(name).Child("EddiesElectronics.sqlite")
  pDatabase.Connect

Catch e As DatabaseException
  MessageBox(e.Message)
End Try</code></pre>



<p>For an <strong>iOS</strong> app, the code would be:</p>



<pre class="wp-block-code"><code>Var source As FolderItem = SpecialFolder.Resource("EddiesElectronics.sqlite")
// Check if our database file already copied on the Documents Sandbox folder
// if not, copy the database file from Resources bundle/directory

If Not SpecialFolder.Documents.Child("EddiesElectronics.sqlite").Exists Then
  source.CopyTo(SpecialFolder.documents)
End If

Try
  // Create a SQLiteDatabase instance and try to open database file from
  // the path
  pDatabase = New SQLiteDatabase
  Var f As FolderItem = SpecialFolder.Documents
  pDatabase.DatabaseFile = f.Child("EddiesElectronics.sqlite")
  Call pDatabase.Connect
  
Catch e As RuntimeException
  MessageBox(e.Message)
End Try</code></pre>



<p>If you&#8217;re working on <strong>Xojo Cloud</strong>, the code is even shorter. First, make sure that the Copy File Build Step has the following values in the Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Destination:</strong> Contents Folder</li>



<li><strong>Subdirectory:</strong> Documents</li>
</ul>



<p>Then, the code will be:</p>



<pre class="wp-block-code"><code>Try
  pDatabase = New SQLiteDatabase
  pDatabase.DatabaseFile = SpecialFolder.Documents.Child("EddiesElectronics.sqlite")
  pDatabase.Connect
Catch e As RuntimeException
  MessageBox(e.Message)
End Try</code></pre>



<p>What about a <strong>Web</strong> app that you host? That would mean you are in control of the folder/directory you want to use to store the app resources. Thus, it wouldn&#8217;t make much sense to automate this process (but it is certainly doable following the same principles).</p>



<h2 class="wp-block-heading">3. Simplifying the Process</h2>



<p>What we have just done works, but it means you need to change the database file name, probably for every app you build. It also means that you&#8217;ll be writing the same code snippet again and again in every new app. Wouldn&#8217;t it be great to be able to extend the SQLiteDatabase in order to simplify that?</p>



<p>Well, let&#8217;s do that! Start by adding a new Module to the example project (for example, one named &#8220;DatabaseExtensions&#8221;) with a couple of methods on it.&nbsp;The first method will be the one executed on our Desktop, Web and Console apps, because all of these targets use the SQLiteDatabase class.</p>



<p>Add a new method using the following signature in the just-created Module:</p>



<pre class="wp-block-code"><code>OpenDatabase(databaseName As String)</code></pre>



<p>It extends the SQLiteDatabase class, adding a new method that takes as parameter the name of the file we want to copy on the &#8220;work&#8221; folder/directory.</p>



<p>The code you should type on this method is:</p>



<pre class="wp-block-code"><code>pDatabase = New SQLiteDatabase

#If TargetDesktop Or TargetConsole Or TargetWeb Then

  Var source As FolderItem = SpecialFolder.Resource(databaseName)
  Var name As String = app.ExecutableFile.name.NthField(".", 1)
  // Check if there is a folder with the App name in special Application Data
  // if not, create it and copy the database file from Resources bundle/directory
  If Not (SpecialFolder.ApplicationData.Child(name).Exists And SpecialFolder.ApplicationData.Child(name).IsFolder) Then
SpecialFolder.ApplicationData.Child(name).CreateFolder
If Not SpecialFolder.ApplicationData.Child(nam).Child(Source.name).Exists Then source.CopyTo(SpecialFolder.ApplicationData.Child(name))

  Try
    // Create a SQLiteDatabase instance and try to open database file from
    // the path
    pDatabase.DatabaseFile = SpecialFolder.ApplicationData.Child(name).Child(databaseName)
    pDatabase.Connect

  Catch e As DatabaseException
    MessageBox(e.Message)
  End Try

#ElseIf TargetXojoCloud
  Try
    pDatabase.DatabaseFile = SpecialFolder.Documents.Child(databaseName)
    pDatabase.Connect
  Catch e As RuntimeException
    MessageBox(e.Message)
  End Try
#EndIf</code></pre>



<p>Of course, we need to add the &#8220;pDatabase&#8221; property to our Module too: pDatabase As SQLiteDatabase</p>



<p>Now, you&#8217;ll only need to use:</p>



<pre class="wp-block-code"><code>OpenDatabase("EddiesElectronics.sqlite")</code></pre>



<p>With the method selected in the Project Browser, click on the Attributes section of the Inspector Panel (the Cog Wheel icon), and uncheck the &#8220;iOS 64&#8221; checkbox. This way, that method will not be included when compiling for iOS apps.</p>


<div class="wp-block-image is-style-default">
<figure class="aligncenter"><img loading="lazy" decoding="async" width="664" height="886" src="https://blog.xojo.com/wp-content/uploads/2021/09/MethodAttributes.png" alt="" class="wp-image-9367" srcset="https://blog.xojo.com/wp-content/uploads/2021/09/MethodAttributes.png 664w, https://blog.xojo.com/wp-content/uploads/2021/09/MethodAttributes-225x300.png 225w" sizes="auto, (max-width: 664px) 100vw, 664px" /></figure>
</div>


<p>The second method is the one we will be using for iOS apps. The method signature would be:</p>



<pre class="wp-block-code"><code>OpenDatabase(databaseName As String)</code></pre>



<p>Type the following fragment of code in the associated Code Editor:</p>



<pre class="wp-block-code"><code>pDatabase = New SQLiteDatabase

Var source As FolderItem = SpecialFolder.Resource(databaseName)

// Check if the database file is already copied on the Documents Sandbox folder
// if not, copy the database file from Resources bundle/directory

If Not SpecialFolder.Documents.Child(databaseName).Exists Then
  source.CopyTo(SpecialFolder.Documents)
End If

Try
  // Create a SQLiteDatabase instance and try to open database file from
  // the path
  
  Var f As FolderItem = SpecialFolder.Documents 
  pDatabase.DatabaseFile = f.Child(databaseName)
  pDatabase.Connect
  
Catch e As RuntimeException
  MessageBox(e.Message)
End Try</code></pre>


<div class="wp-block-image is-style-default">
<figure class="aligncenter"><img loading="lazy" decoding="async" width="658" height="892" src="https://blog.xojo.com/wp-content/uploads/2021/09/MethodAttributesiOS.png" alt="" class="wp-image-9368" srcset="https://blog.xojo.com/wp-content/uploads/2021/09/MethodAttributesiOS.png 658w, https://blog.xojo.com/wp-content/uploads/2021/09/MethodAttributesiOS-221x300.png 221w" sizes="auto, (max-width: 658px) 100vw, 658px" /></figure>
</div>


<p>Lastly, and with the method item still selected in the Navigator, go to the Attributes section of the Inspector Panel and make sure that the &#8220;iOS 64&#8221; checkbox is the only one selected under the &#8220;Include In&#8221; section. This way, we make sure that the method will be compiled only on iOS targets.</p>



<h2 class="wp-block-heading">To Summarize</h2>



<p>The use of Modules in combination with OOP Class Extension is a good way to get more flexibility when developing your apps, no matter if you are working on Desktop, Web or iOS. And that leads to convenient reutilization of code and less code to maintain through all your projects!</p>



<p>(You can find this article in Spanish <a href="https://www.aprendexojo.com/2021/11/tutorial-3-pasos-para-desplegar-proyectos-sqlite-en-desktop-web-y-ios/">here</a>)</p>



<p><em>Javier Menendez is an engineer at Xojo and has been using Xojo since 1998. He lives in Castellón</em>, <em>Spain and hosts regular Xojo hangouts en español. Ask Javier questions on Twitter at <a href="https://twitter.com/xojoes" target="_blank" rel="noreferrer noopener">@XojoES</a> or on the <a href="https://forum.xojo.com/u/javier_menendez/summary" target="_blank" rel="noreferrer noopener">Xojo Forum</a>.</em></p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
