Create table in mysql using button script

I want to create a table in MySQL database, using button script. Please let me know.

Hi!

First, welcome to the forums.

Second, Short questions like this do not normally result in good answers. The more details you can provide, the better the answers become! :thumb_right: That being said, I’ll take the first stab at it…

Although such things are usually more easily handled in transaction groups, this will create a new, empty table:

[code]query=""“CREATE tableName(
ndx INT NOT NULL AUTO_INCREMENT
t_stamp DATETIME NOT NULL
col1Name VARCAHR(20) NOT NULL
col2Name INT
col3Name FLOAT
PRIMARY KEY (ndx)
)”""

system.db.runUpdateQuery(query, datasource)[/code]

To be honest, doing something like this through a button script does not seem like a good workflow. Perhaps if you can tell us what you are trying to do, we can either explore this further, or suggest alternatives. :slight_smile:

Hi,
Thank you for the suggestions.

I am trying to show the event log using audit log table. In the audit log table we have only tag path, for tag descriptions I had prepared one table. At the time of retrieving the events I am just pulling the descriptions for the tag from newly created table.

Now it is working fine, but I want to give this backup to our client. Hence I am trying to create table and insert the tags and there descriptions in the table using script, which will be easier to commission the system.

Thanks once again.