# Create SQL Database Table via Python

**URL:** <https://forum.inductiveautomation.com/t/create-sql-database-table-via-python/16532>\
**Category:** Ignition\
**Created:** [January 10, 2018, 1:28am UTC](https://forum.inductiveautomation.com/t/create-sql-database-table-via-python/16532 "2018-01-10T01:28:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 10, 2018, 1:28am UTC](https://forum.inductiveautomation.com/t/create-sql-database-table-via-python/16532/1 "2018-01-10T01:28:56Z")

</div>

Hi,

Is it possible to create a database table in the project’s default SQL provider (e.g. MySQL) in Ignition? (Python?)

I have tried to use this:

```auto
SQLCreate = "CREATE TABLE cfgTrends (Area NVARCHAR(25) NOT NULL)"
system.db.runUpdateQuery(SQLCreate)

```

But i get the generic error ‘Error executing system.db.runUpdateQuery(…)’

In the gateway, the database configuration is set to a user that has admin privileges, and I can use the exact same SQL  
statement and same user to create the table in the MySQL Workbench.

Is this possible to do?

I want to do this for custom tables so that they auto-create themselves if they don’t exist.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [January 10, 2018, 4:58am UTC](https://forum.inductiveautomation.com/t/create-sql-database-table-via-python/16532/2 "2018-01-10T04:58:04Z")

</div>

Yes, you can run any SQL query against the database, including create and delete statements.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 10, 2018, 6:21am UTC](https://forum.inductiveautomation.com/t/create-sql-database-table-via-python/16532/3 "2018-01-10T06:21:01Z")

</div>

Hmm, I keep getting the same error:

(REMOVED)

Any advice?

Cheers!

Edit: scratch that, it just started working??

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [January 10, 2018, 8:06am UTC](https://forum.inductiveautomation.com/t/create-sql-database-table-via-python/16532/4 "2018-01-10T08:06:19Z")

</div>

What was the error?

More words to meet limit

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [January 10, 2018, 8:28am UTC](https://forum.inductiveautomation.com/t/create-sql-database-table-via-python/16532/5 "2018-01-10T08:28:26Z")

</div>

I had already created the table, so the error text I copied just said that it already existed. However I was getting another error prior to creating the table manually that unfortunately I didn’t copy… hence why I removed the error text
