Parse csv File into Database through Perspective


I was wondering if someone could help me with uploading a csv file to an MSSQL Database through a Perspective Session? I have looked at the File Upload Guide however I am looking to directly put the csv data into columns on the Database.

I have uploaded files into a database using Pandas & pyodbc previously however that doesn’t seem to be supported in Ignitions version of Python (think its using Jython).

Any help with this would be greatly appreciated. Let me know if any more information is needed

You’ll have to use the file upload component, because all scripting in Perspective runs on the gateway, and you have to get the data to the gateway somehow. From the file upload component, it’s relatively easy to implement an onFileReceived hook. You can then use the Python builtin csv module to read the file, or manually parse it using Python’s string manipulation. Getting it into the database is mostly an exercise left to you, since your DB structure could be highly variable, but it’s pretty easy to run batched queries from Ignition that can be quite efficient (there’s been quite a few threads on this forum about inserting CSV data into a database).