Create SQL Database Table via Python

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:

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.

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

Hmm, I keep getting the same error:

(REMOVED)

Any advice?

Cheers!

Edit: scratch that, it just started working??

What was the error?

More words to meet limit

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