# Sqlite

**URL:** <https://forum.inductiveautomation.com/t/sqlite/11495>\
**Category:** Archived Topics\
**Created:** [April 12, 2016, 11:17pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495 "2016-04-12T23:17:09Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![wweb](https://avatars.discourse-cdn.com/v4/letter/w/54ee81/32.png) [@wweb](https://forum.inductiveautomation.com/u/wweb)\
**Post date:** [April 12, 2016, 11:17pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495/1 "2016-04-12T23:17:09Z")

</div>

Can an Ignition Project connect to a SQLite database? If so, how?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 13, 2016, 1:04am UTC](https://forum.inductiveautomation.com/t/sqlite/11495/2 "2016-04-13T01:04:59Z")

</div>

SQLite isn’t packaged with Ignition as an exposed driver, so you’ll have to use the “Create new JDBC Driver…” procedure with a downloaded driver package. I believe it’s [this one](https://bitbucket.org/xerial/sqlite-jdbc/downloads).

---

<div class="post-metadata">

**Author:** ![wweb](https://avatars.discourse-cdn.com/v4/letter/w/54ee81/32.png) [@wweb](https://forum.inductiveautomation.com/u/wweb)\
**Post date:** [April 13, 2016, 5:30pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495/3 "2016-04-13T17:30:30Z")

</div>

Thanks! I was able to get the status of the connection to “Valid”. However, when I can’t get the transaction group to write to the database. So I am wondering if the problem lies with the Translator, and needing something custom.

---

<div class="post-metadata">

**Author:** ![Derekr](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/derekr/32/4945_2.png) [@Derekr](https://forum.inductiveautomation.com/u/Derekr)\
**Post date:** [July 13, 2016, 9:26pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495/4 "2016-07-13T21:26:12Z")

</div>

Did you ever resolve this issue? I was able to create a connection to sqlite that was Valid, but I cannot query the db I get an Error:SQL error or missing database (no such table: BASIC\_SCHEDULES  
even though I know that table exists.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [November 4, 2018, 2:50pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495/5 "2018-11-04T14:50:00Z")

</div>

It will be usefull if SQLITE connector was directly available for some user’s db in Ignition 7.9.X or 8.0

---

<div class="post-metadata">

**Author:** ![j11](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/j11/32/8793_2.png) [@j11](https://forum.inductiveautomation.com/u/j11)\
**Post date:** [April 29, 2019, 10:56pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495/6 "2019-04-29T22:56:00Z")

</div>

I was also able to get a valid connection, and it creates the sqlite file, but I wasn’t able to write data to it. Was anyone able to get SQLite working?

---

<div class="post-metadata">

**Author:** ![enertec](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@enertec](https://forum.inductiveautomation.com/u/enertec)\
**Post date:** [January 3, 2020, 12:17pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495/7 "2020-01-03T12:17:41Z")

</div>

Hello. Could You say please, how did You get the valid connection?  
I have SQLite db file laying on the one Linux system, and Ignition running on the another Linux system, how should i establish connection between them?  
Please help, examples would be appreciated.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 3, 2020, 1:01pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495/8 "2020-01-03T13:01:25Z")

</div>

SQLite is not designed for use over a network. As in, the developers created it to be local and have not intention of adding network support. The issue can be forced by using your OS’s network file sharing features, but that is buggy and slow and can interfere with other access to that DB.

If you need network access, you really need a full client-server DB implementation. If you need it to be free, use PostgreSQL, MariaDB, or MySQL. (In that order, in my not-so-humble opinion.)

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [January 3, 2020, 3:18pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495/9 "2020-01-03T15:18:01Z")

</div>

SQLite is great, but for specific purposes. We use SQLite in Ignition to pre-load data down to equipment… We update the connection string to a new DB file and initialize it, then we load data into the SQLite DB (local file on the GW), then we close the connection and download the resulting DB to a client machine where that system now uses the SQLite DB file.

Locally SQLite is great, but not a LAN DB system. I think of it more as a relational ini file 🙂

Anyway, once you create the SQLite connection, you need to init the DB file the first time and create your tables just like any other DB. The first time we open the SQLite file we also set some other preferences in SQLite related to indexing and keys, remember this is a regular DB just like a server, you want to config it for what your needs are.

---

<div class="post-metadata">

**Author:** ![lshirley](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lshirley/32/6627_2.png) [@lshirley](https://forum.inductiveautomation.com/u/lshirley)\
**Post date:** [May 14, 2020, 5:45pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495/10 "2020-05-14T17:45:26Z")

</div>

Is there anyway you can give me a good example of this? I need pretty much the same thing. I need to be able to sync a remote database down to the local machine (only a single 3 or 4 column table) and then use that data on the local machine (as it will be outside the network coverage area).

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [May 14, 2020, 7:24pm UTC](https://forum.inductiveautomation.com/t/sqlite/11495/11 "2020-05-14T19:24:28Z")

</div>

Here is how I use it. This only works for a low volume of “hits” as it can only serve one request at a time.

Prereq: There is a SQLite DB connection on the gateway that remains disabled.

I use WebDev to request the SQLite DB file to an external system. The system sends a get request to WebDev.

As part of the request it calls a function with some code like below to generate the DB.

```auto
# Create a temp file
tempDB = system.file.getTempFile('db')

# Enable and the DB
system.db.setDatasourceConnectURL('sqlite', 'jdbc:sqlite:%s' % tempDB)
system.db.setDatasourceEnabled('sqlite', 1)

# Setup the DB, create tables, add indexes, etc...
sql = """
DROP TABLE IF EXISTS `data`;
CREATE TABLE `data` (
	`ID`	NUMERIC,
	`Result`	REAL
);
"""
system.db.runUpdateQuery(sql, 'sqlite')

#
# Insert stuff!!
#

# Remove the connection to the DB so we can download it
system.db.setDatasourceEnabled('sqlite', 0)
	
# Return the server path to the DB file	
return tempDB

```

Once the tempDB returns to the WebDev script, read the file and send it to the client.

```auto
# Strem the file to the client if all went well
return {'file': tempDB, 'contentType':'application/x-sqlite3'}

```
