Using library WagoLibMySQL to communicate with MySQL-Databases Application note



Similar documents
Remote Connection to a WAGO using a High-Speed Internet connection Application note

Using the WAGO PROFINET Coupler as Remote I/O with a Siemens S7 PLC

Transmitting s in a local network with a WAGO CONTROLLER Application note

Connect Ethernet-Controller to TO-PASS web portal via GPRS-Router Application note

Transmitting s with the WAGO IPC Application note

Using the SysLibFile.lib and the WagoLibFtp.lib for file access Application note

WAGO-I/O-SYSTEM. Using library WagoLibMSSQL_03.lib in CoDeSys 2.3 for interface to Microsoft SQL Server 200x. Application Note

Accessing EtherNet/IP Network Variables in a WAGO with a ControlLogix PLC Application note

Ethernet/IP Comms between a WAGO and a Mettler Toledo JAGXTREME Terminal Application note

Ethernet PFC Sending Application note

WAGO PFC 750-8xx Interface to Horner HMI Application note

WAGO-I/O-SYSTEM in ABB robot control systems Application note

Configuration a Profibus-DP node using Step7 and WAGO-I/O components Application note

Transmitting s with the library "WagoLibMail_02.lib" Application note

Sending / receiving SMS using a GSM modem Application note

Application note. A103202, English Version 1.0.1

Application Note. WAGO EtherNet/IP Communications with a CompactLogix PLC Using Explicit Messaging. A500620e, English Version: 1.0.

EtherNet/IP communications between a WAGO PFC and a SICK IVC-2D Camera Application note

WAGO PFC as a MODBUS MASTER Application note

Using library WagoLibHttp_02.lib to communicate with remote web server Application note

Project management integrated into Outlook

Modular I/O System ETHERNET StarterKit Quick Start ETHERNET Fieldbus Controller

Installing Drupal on Your Local Computer

MOODLE Installation on Windows Platform

Administrator s Guide for the Polycom Video Control Application (VCA)

Application note: Connecting the to a Database

WAGO Software CODESYS Library WagoLibDiagnosticIDs.lib for accessing the internal diagnostics protocol

QUANTIFY INSTALLATION GUIDE

Oracle Enterprise Manager

Setting Up ALERE with Client/Server Data

How to set up Outlook Anywhere on your home system

Abstract. For notes detailing the changes in each release, see the MySQL for Excel Release Notes. For legal information, see the Legal Notices.

Manual TC3 PLC HMI. TwinCAT 3. Version: Date: Order No.: TF1800

Virtual CD v10. Network Management Server Manual. H+H Software GmbH

User Guide. DocAve Lotus Notes Migrator for Microsoft Exchange 1.1. Using the DocAve Notes Migrator for Exchange to Perform a Basic Migration

Lepide Active Directory Self Service. Installation Guide. Lepide Active Directory Self Service Tool. Lepide Software Private Limited Page 1

SQL Server 2008 R2 Express Edition Installation Guide

SQL Server Setup for Assistant/Pro applications Compliance Information Systems

MySQL Quick Start Guide

The Project Management Software for Outlook, Web and Smartphone

MySQL Manager. User Guide. July 2012

Specops Command. Installation Guide

Oracle Enterprise Manager

Job Scheduler User Guide IGSS Version 11.0

Getting Started with Dynamic Web Sites

Windows XP Exchange Client Installation Instructions

SMS Database System Quick Start. [Version 1.0.3]

Manual. Source Control. TwinCAT 3. Version Date

DOCUMENTATION MySQL BACKUP & RESTORE OPERATIONS

Configuring IBM Cognos Controller 8 to use Single Sign- On

CIMHT_006 How to Configure the Database Logger Proficy HMI/SCADA CIMPLICITY

Deltek Touch Time & Expense for Vision 1.3. Release Notes

Validity 1. Improvements in STEP 7 2. Improvements in WinCC 3. Simatic. Readme. Readme

Publish Joomla! Article

Installation Guide for Microsoft SQL Server 2008 R2 Express. October 2011 (GUIDE 1)

Nortel Networks Symposium Call Center Server Symposium Database Integration User s Guide

Installation Instructions

42goISP Documentation

ISPConfig Documentation

MySQL quick start guide

Connect to MySQL or Microsoft SQL Server using R

SELF SERVICE RESET PASSWORD MANAGEMENT BACKUP GUIDE

BIGPOND ONLINE STORAGE USER GUIDE Issue August 2005

Upgrading from MSDE to SQL Server 2005 Express Edition with Advanced Services SP2

Print Audit 6 - SQL Server 2005 Express Edition

Enabling Backups for Windows and MAC OS X

File Auditor for NAS, Net App Edition

Parallels Panel. Parallels Small Business Panel 10.2: User's Guide. Revision 1.0

NTT Web Hosting Service [User Manual]

Immotec Systems, Inc. SQL Server 2005 Installation Document

Backup and Restore MySQL Databases

Setup Soft PLC Technical handbook

Password Management. Password Management Guide HMS 9700

AN4108 Application note

Windows Server Update Services 3.0 SP2 Step By Step Guide

FileMaker 14. ODBC and JDBC Guide

DOCUMENTATION MICROSOFT SQL BACKUP & RESTORE OPERATIONS

Installation Guide. . All right reserved. For more information about Specops Inventory and other Specops products, visit

Outlook Profile Setup Guide Exchange 2010 Quick Start and Detailed Instructions

1. CONFIGURING REMOTE ACCESS TO SQL SERVER EXPRESS

Modular I/O System Quick Start for WAGO-I/O-IPC /000-xxx Features

Configuring Network Load Balancing with Cerberus FTP Server

Configuring Microsoft Internet Information Service (IIS6 & IIS7)

Business Portal for Microsoft Dynamics GP Field Service Suite

Cloud Tools Reference Guide. Version: GA

Microsoft SQL Server Installation Guide

MySQL Installer Guide

Creating a System DSN for Crystal Reports to Access a Sentinel Server Database. Configuration Guide Version 1.0

Project management integrated into Outlook

Installing Drupal 8 on Windows 7 with XAMPP. I am trying to install Drupal 8 on my Windows machine as a development system.

CONFIGURING MICROSOFT SQL SERVER REPORTING SERVICES

LABSHEET 1: creating a table, primary keys and data types

Maintaining the Content Server

Lifecycle Service Tool. Operator's manual

Project management integrated into Outlook

StreamServe Persuasion SP5 Control Center

14.1. bs^ir^qfkd=obcib`qflk= Ñçê=emI=rkfuI=~åÇ=léÉåsjp=eçëíë

White Paper. Installation and Configuration of Fabasoft Folio IMAP Service. Fabasoft Folio 2015 Update Rollup 3

Business Portal for Microsoft Dynamics GP Key Performance Indicators

Transcription:

Using library WagoLibMySQL to communicate with MySQL-Databases, English Version 1.1.0

ii General Copyright 2010 by WAGO Kontakttechnik GmbH & Co. KG All rights reserved. WAGO Kontakttechnik GmbH & Co. KG Hansastraße 27 D-32423 Minden Phone: +49 (0) 571/8 87 0 Fax: +49 (0) 571/8 87 1 69 E-Mail: info@wago.com Web: http://www.wago.com Technical Support Phone: +49 (0) 571/8 87 5 55 Fax: +49 (0) 571/8 87 4 30 E-Mail: support@wago.com Every conceivable measure has been taken to ensure the correctness and completeness of this documentation. However, as errors can never be fully excluded we would appreciate any information or ideas at any time. We wish to point out that the software and hardware terms as well as the trademarks of companies used and/or mentioned in the present manual are generally trademark or patent protected.

Table of Contents iii TABLE OF CONTENTS 1 Important comments... 4 1.1 Legal principles... 4 1.1.1 Copyright... 4 1.1.2 Personnel qualification... 4 1.1.3 Intended use... 4 1.2 Range of validity... 5 1.3 Symbols... 5 2 Description... 6 3 Set up Environment... 7 3.1 Install XAMPP... 7 3.2 Create database testdb... 8 3.3 Create database account... 10 3.4 Restart database or reload privileges... 12 4 The library WagoLibMySql_02.lib... 13 5 Example_01... 14 6 Example_02... 15

4 Important comments 1 Important comments 1.1 Legal principles 1.1.1 Copyright To ensure fast installation and start-up of the units described in this manual, we strongly recommend that the following information and explanation is carefully read and adhered to. This manual is copyrighted, together with all figures and illustrations contained therein. Any use of this manual which infringes the copyright provisions stipulated herein, is not permitted. Reproduction, translation and electronic and photo-technical archiving and amendments require the written consent of WAGO Kontakttechnik GmbH & Co. KG. Non-observance will entail the right of claims for damages. 1.1.2 Personnel qualification 1.1.3 Intended use The use of the product detailed in this manual is exclusively geared to specialists having qualifications in PLC programming, electrical specialists or persons instructed by electrical specialists who are also familiar with the valid standards. WAGO Kontakttechnik GmbH & Co. KG declines all liability resulting from improper action and damage to WAGO products and third party products due to non-observance of the information contained in this manual. For each individual application, the components supplied are to work with a dedicated hardware and software configuration. Modifications are only admitted within the framework of the possibilities documented in the manuals. All other changes to the hardware and/or software and the non-conforming use of the components entail the exclusion of liability on part of WAGO Kontakttechnik GmbH & Co. KG. Please direct any requirements pertaining to a modified and/or new hardware or software configuration directly to WAGO Kontakttechnik GmbH & Co. KG.

Important comments 5 1.2 Range of validity 1.3 Symbols This application note is based on the stated hardware and software of the specific manufacturer as well as the correspondent documentation. This application note is therefore only valid for the described installation. New hardware and software versions may need to be handled differently. Please note the detailed description in the specific manuals. Danger Always observe this information to protect persons from injury. Warning Always observe this information to prevent damage to the device. Attention Marginal conditions must always be observed to ensure smooth operation. ESD (Electrostatic Discharge) Warning of damage to the components by electrostatic discharge. Observe the precautionary measure for handling components at risk. Note Routines or advice for efficient use of the device and software optimisation. More information References to additional literature, manuals, data sheets and INTERNET pages

6 Description 2 Description This application note describes how to communicate with a MySQL database directly, based on native MySQL protocol to transmit SQL-Statements. SQL is the acronym for Structured-Query-Language(SQL) and defines standard command set to access or manipulate data like SELECT, INSERT, UPDATE, DELETE inside a database. Also defined are SQL commands to modify the structure of a database self, like CREATE, DROP, ALTER, and more. The focus of this application note points to the transfer of data between a WAGO Ethernet-Controller and a MySQL database by SQL statements. The easiest way to get running MySQL database is installing XAMPP, but any other setup of MySQL above version 4.1 should work. XAMPP is a free and open source cross-platform web server package, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages. This application note only utilize the MySQL database, webserver and scripting engines are not used. The examples of this application note requires a suitable database structure for operating. Read next how to setup the needed environment.

Set up Environment 7 3 Set up Environment 3.1 Install XAMPP This chapter guides you step-by-step to your own MySQL solution. Download the XAMPP package for your operating system from http://www.apachefriends.org/en/xampp.html and follow the installation instructions. This application note is created on a Microsoft operating system. Please keep in mind that XAMPP provides an easy to install system for developing and testing of web solutions. Care should be taken when applying security settings for your own application. Test: After Apache starts, open the URL http://localhost or http://127.0.0.1 and examine all of the XAMPP examples and tools. To check that all required services are running, go to the XAMPP menu and press Status. You should see all needed services activated (PHP, MySQL). The next step is creating the specific database for our examples.

8 Set up Environment 3.2 Create database testdb Open the MySQL administration tool by typing URL http://localhost or http://127.0.0.1 and click the PhpMyAdmin item in the XAMPP menu. Click on Databases to open the following dialog. Insert the name of your new database and press the Create button. In this application note, we will create a database called testdb.

Set up Environment 9 An empty database has been created. The next step is to create tables inside the database. Switch to the tab Import, and browse to the files: - /Example01/Database/CreateTableExample01.sql - /Example02/Database/CreateTableExample02.sql.. Press the Go button to create tables. Now you should see the two tables atable and data. Next step is to create a database account for our WAGO-Ethernet-Controllers.

10 Set up Environment 3.3 Create database account It is not a good idea to use the default admin-account inside the PLC-program. Better is using an additional account with limited privileges. Use link Rights to open the Current User view. Use link Add user to to open the New User view.

Set up Environment 11 In this application note we expect a user with following settings. Param Value: Description: Username user. Name of database user account. Password password Password of database user account Access Any Host IP-Address,r hostname or placeholder Any_Host Privileges SELECT, INSERT, UPDATE, DELETE Privileges define the the set of operations allowed for this account. Update the New User view. Press the Go button to create the new database account. Now the new database account is configured, but currently not active.

12 Set up Environment 3.4 Restart database or reload privileges To activate the new database account you have to reload privileges. This could be done by stopping and restart the whole database or use phpmyadmin to force reload of privileges. To restart the whole database open the XAMPP Control Panel. Press button Stop afterwards press Start. Alternatively you can force reloading of privileges with link reload privileges in phpadmin. The server is now configured and ready to use.

The library WagoLibMySql_03.lib 13 4 The library WagoLibMySql_03.lib The library WagoLibMySql_03.lib provide function blocks to communicate with MySQL-Database-Servers version 4.1 and above. The principal item of this library are function blocks Execute and Query. Function block MySql_Execute is designed for all SQL-Statements who do not respond with a resultset, such as INSERT, UPDATE, DELETE, CREATE, ALTER, DROP and so, who just return OK or ERROR. Function block MySql_Query is designed for SQL-SELECT-Statements who respond with a resultset. The resultset are stored in an optimized format, use function MySql_GetStringValue() to convert field data into any IEC-Type. All non numeric SQL param values must be quoted with an apostroph( ). Because apostroph( ) is also CoDesys-String-Start-End-Identifier. To use a apostroph( ) inside a CoDeSys-String type $27 or $ Example: (* Prepare SQL-Insert-Statement *) assqlstatement1[0] := 'INSERT INTO atable '; assqlstatement1[1] := '( abool, abyte, aword, adint, areal, '; assqlstatement1[2] := ' astring, adt, atime, audint ) '; assqlstatement1[3] := 'VALUES '; assqlstatement1[4] := '( TRUE, 17, 32333, 1111111, 1.42, '; assqlstatement1[5] := ' $'Hallo$', $'2010-08-13 11:56:42$', '; assqlstatement1[6] := ' $'13:12:57$', 62222 )'; assqlstatement1[7] := ''; (* End of SQL-Statement *) This library make extensive use of global variables to allow optimize memory usage depending customer requirements. You can modify the "length" and number of elements in "assqlstatement" by hiding libraries global constants with global constants of same name in your project: - gcmysql_isqlupperbound: Defines the UpperBound of "assqlstatement",to provide an SQL statement as"array [0..UpperBound] OF STRING(Size)" - gcmysql_isqllength: Defines the Size in byte of an array element of "assqlstatement", to provide an SQL statement as "ARRAY [0..UpperBound] OF STRING(Size)". For details see library description ml0600e WagoLibMySql_02.pdf.

14 Example_01 5 Example_01 Open WagoLibMySql_Example01.pro in CodeSys 2.3. You will find a PLC program written in FUP, who uses function blocks: - MySql_Login to open a database connection. - MySql_Execute for insert and update of data in table data. - MySql_Query is used to read back the complied content of table data. - MySql_GetStringValue() is used to convert QueryData into IEC-datatypes. - MySql_Logout to close the database connection Update inputs shost, susername, spassword depending your environment. To let the example do something toggle input xstart by double click and write it with [Ctrl] + [F7]. Information about current state of operation can be found at output sstatus.

Example_02 15 6 Example_02 Open WagoLibMySql_Example02.pro in CodeSys 2.3. You will find a PLC program written in ST, who uses function blocks: - MySql_Login to open a database connection. - MySql_Execute for insert and update of data in table data. - MySql_Query is used to read back the complied content of table data. - MySql_GetStringValue() is used to convert QueryData into IEC-datatypes. - MySql_Logout to close the database connection Update inputs shost, susername, spassword depending your environment. To let the example do something toggle input xdoit by double click and write it down, with [Ctrl] + [F7]. Information about current state of operation can be found at output sstatus.

WAGO Kontakttechnik GmbH & Co. KG Postfach 2880 D-32385 Minden Hansastraße 27 D-32423 Minden Telefon: 05 71/8 87 0 Telefax: 05 71/8 87 1 69 E-Mail: info@wago.com Internet: http://www.wago.com