Visual FoxPro Accessing MySQL. presented to The Atlanta FoxPro Users Group June 19 th, 2007

Similar documents
Backup and Restore MySQL Databases

How-To: MySQL as a linked server in MS SQL Server

Application note: Connecting the to a Database

UQC103S1 UFCE Systems Development. uqc103s/ufce PHP-mySQL 1

Short notes on webpage programming languages

Pemrograman Web. 1. Pengenalan Web Server. M. Udin Harun Al Rasyid, S.Kom, Ph.D

Getting Started with Dynamic Web Sites

Monitoring MySQL. Presented by, MySQL & O Reilly Media, Inc. A quick overview of available tools

Database Setup. Coding, Understanding, & Executing the SQL Database Creation Script

Mercury Users Guide Version 1.3 February 14, 2006

Build it with Drupal 8

MSSQL quick start guide

INSTALLING, CONFIGURING, AND DEVELOPING WITH XAMPP

Setting Up ALERE with Client/Server Data

Lesson 7 - Website Administration

How To Install Amyshelf On Windows 2000 Or Later

How To Backup A Database On A Microsoft Powerpoint 3.5 (Mysqldump) On A Pcode (Mysql) On Your Pcode On A Macbook Or Macbook (Powerpoint) On

This guide specifies the required and supported system elements for the application.

SQL Databases Course. by Applied Technology Research Center. This course provides training for MySQL, Oracle, SQL Server and PostgreSQL databases.

Search help. More on Office.com: images templates

CSCI110 Exercise 4: Database - MySQL

Database Management System Choices. Introduction To Database Systems CSE 373 Spring 2013

LAMP : THE PROMINENT OPEN SOURCE WEB PLATFORM FOR QUERY EXECUTION AND RESOURCE OPTIMIZATION. R. Mohanty Mumbai, India

Using SQL Server Management Studio

Installing buzztouch Self Hosted

Graham Jones. Internet Psychologist. How to choose the right web host

Migrating to Azure SQL Database

To use MySQL effectively, you need to learn the syntax of a new language and grow

DIPLOMA IN WEBDEVELOPMENT

GETTING STARTED WITH SQL SERVER

Instructions. Introduction

IceWarp Server Windows Installation Guide

The single biggest mistake many people make when starting a business is they'll create a product...

Use the ADO Control in your Visual Basic 6 projects

Installing Drupal on Your Local Computer

MAMP 3 User Guide! March 2014 (c) appsolute GmbH!

Intro to Databases. ACM Webmonkeys 2011

Installing a local web server José Manuel Bouzán Matanza

Setting up an MS SQL Server for IGSS

Spector 360 Deployment Guide. Version 7.3 January 3, 2012

2015, André Melancia (Andy.PT) 1

Advantage Database Server or Microsoft SQL Server which one is right for you?

mylittleadmin for MS SQL Server 2005 from a Webhosting Perspective Anthony Wilko President, Infuseweb LLC

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

Database Forms and Reports Tutorial

Installation and Deployment

MOODLE Installation on Windows Platform

How To Create An Easybelle History Database On A Microsoft Powerbook (Windows)

AJ Matrix V5. Installation Manual

Using the SQL Server Linked Server Capability

Connect to MySQL or Microsoft SQL Server using R

MySQL Quick Start Guide

SETTING UP AND RUNNING A WEB SITE ON YOUR LENOVO STORAGE DEVICE WORKING WITH WEB SERVER TOOLS

Online shopping store

Accessing Your Database with JMP 10 JMP Discovery Conference 2012 Brian Corcoran SAS Institute

Sequential Query Language Database Networking Using SQL

Microsoft Access Basics

BillQuick Installation Guide for Microsoft SQL Server 2005 Express Edition

Jenesis Software - Podcast Episode 2

Overview of Databases On MacOS. Karl Kuehn Automation Engineer RethinkDB

Exploring Microsoft Office Access Chapter 2: Relational Databases and Multi-Table Queries

Application Development

Microsoft SQL Server Installation Guide

Installation Instructions

EMBL-EBI. Database Replication - Distribution

Microsoft SQL Server Installation Guide

MAGENTO HOSTING Progressive Server Performance Improvements

Pivot Charting in SharePoint with Nevron Chart for SharePoint

Create a New Database in Access 2010

Benchmarking and monitoring tools

PHP Tutorial From beginner to master

ISI ACADEMY Web applications Programming Diploma using PHP& MySQL

Introduction to Microsoft Access 2003

Apache 2.0 Installation Guide

REDCap General Security Overview

Seamless Web Data Entry for SAS Applications D.J. Penix, Pinnacle Solutions, Indianapolis, IN

MySQL Enterprise Backup

Relational Databases for the Business Analyst

EXT: News Event. Extension Key: mbl_newsevent Copyright , Mathias Bolt Lesniak,

Lucid Key Server v2 Installation Documentation.

TAMS Analyzer 3 and Multi-User Projects. By Matthew Weinstein

Simple Document Management Using VFP, Part 1 Russell Campbell russcampbell@interthink.com

Upgrading MySQL from 32-bit to 64-bit

Moving from DBF to SQL Server Pros and Cons

Using Microsoft Access Front End to NIMSP MySQL Database

ODBC Group Policy Settings

Commercial Database Software Development- A review.

Access Tutorial 8: Combo Box Controls

FileMaker Server 15. Getting Started Guide

Developing Web Applications for Microsoft SQL Server Databases - What you need to know

How to Install SMTPSwith Mailer on Centos Server/VPS

Server side scripting and databases

Testing Web Applications for SQL Injection Sam Shober

Transcription:

Visual FoxPro Accessing MySQL presented to The Atlanta FoxPro Users Group June 19 th, 2007

Comparing MySQL with the VFP DBC, SQL Server, PostgreSQL VFP DBC Pros: 1. Very fast 2. Free DBC multiuser access and distribution 3. Transactions 4. Referential Integrity 5. Stored Procedures 6. Can be run FROM a variety of file servers running various operating systems 7. Poor ODBC support by web hosting companies 8. Official support will stop sometime after 2015 9. Did we mention, very fast! MySQL Pros: 1. Multiuser access 2. Transactions 3. Referential Integrity (recent) 4. Stored Procedures (recent) 5. Unlimited database sizes 6. Fast! 7. Free? 8. Available with common, inexpensive web hosting plans 9. Can be run on a variety of operating systems SQL Server Pros: 1. Multiuser access (not SQLExpress!) 2. Transactions 3. Referential Integrity 4. Stored Procedures 5. Unlimited database sizes 6. Fast 7. Jobs PostgreSQL Pros: 1. Free (really free!) multiuser access and distribution 2. Transactions 3. Referential Integrity 4. Stored Procedures 5. Unlimited database sizes 6. Fast 7. Available with some, inexpensive web hosting plans 8. Can be run on a variety of operating systems 9. Did we mention FREE?!?

VFP Cons: 1. 2 Gig limit 2. More network traffic 3. Updating database and table structures difficult MySQL Cons: 1. Requires a server that is more than a File Server 2. May not be free? SQL Server Cons: 1. Requires a server that is more than a File Server 2. Not free 3. Licensing pains 4. Closed source 5. Requires a Microsoft Windows server 6. You may be forced to upgrade to keep support PostgreSQL Cons: 1. Requires a server that is more than a File Server 2. Not as common in inexpensive web hosting plans 3. GUI tools may not be as slick as other offerings (But who cares, really.)

How To Install MySQL I won't go into too much detail here about how to install MySQL. Partly because it is so easy. Go to http://mysql.org/downloads/ and download the server for your platform. Make sure to check out the GUI Tools section. It will really help administer your MySQL installation. I'll talk about the GUI tools a bit later. Another approach to take is to take a look at XAMPP at http://www.apachefriends.org/en/xampp.html. XAMPP is a suite of FOSS goodness that includes Apache, MySQL, PHP, PHPmyAdmin and other great packages. All in one easy to install bundle. Recommended. One note is that XAMPP has the INNODB engine turned off by default. You'll need to adjust the my.cnf file to have it turned on. More on this later.

What GUI tools are available to Administer and query MySQL There is not a shortage of GUI tools to help you administer and query the data that you have stored in MySQL. Here are just a couple of the tools. Some are current, others are being moonlighted, and others are still in beta. 1. MySQL Administrator An administrative tool that enables you to control your environment and gain better visibility into how your databases are operating. 2. MySQL Control Center Another administrative tool that allows you to create and modify most of the database objects in a trivial manner.

3. MySQL Query Browser One of the easiest tools for creating, executing, and optimizing SQL queries for your database. 4. PHPMyAdmin A web based administrative tool that allows you to create databases, tables, indexes, administer rights, etc. All in a browser.

How to upsize VFP structures and data to MySQL 1. Upsizing wizard in VFP requires a DBC 2. Stru2MySQL.prg by Ed Leafe. 3. Stru2MySQL_2.prg additions by Kevin Cully The changes that I have made to Stru2MySQL include: 1. Script files are created for each open cursor/table 2. A script file is created that contains all of the individual script files. 3. The program creates an object, that can have properties/options set to better control the output. 4. Additional MySQL commands are added to the script which drops existing tables if they exist. 5. The program allows for alternative engines to be specified. INNODB vs. MyISAM as an example. I'll have the Stru2MySQL_2.prg uploaded back to Ed Leafe's downloads page at http://leafe.com/dls/vfp. Feel free to make improvements and donate back to the community.

ENGINE talk MySQL allows for different databases to be governed by different engines. Two of the most popular is MyISAM and INNODB. To bottom line the difference is that MyISAM does not support transactions, while INNODB does. The performance difference between the two engines is just a couple of percentage points, one way or the other based on my simple benchmarks that I have performed. There are other benchmark statistics performed by far smarter and qualified people than myself, so run some tests before you get started. Remember that XAMPP has the INNODB engine turned off by default. A quick edit to my.cnf will add it back in after a restart. Connecting, Querying and updating data from VFP The connection string to MySQL looks something like this: Driver={MySQL ODBC 3.51 Driver};Port=3306;Server=192.168.1.128 ;Database=AFUG;Uid=afug;Pwd=afug12345 You can use the SQLCONNECT and SQLEXEC command commands to gain access to your databases and tables. I'm sorry that this is so sparse here, but I'm running out of time. If you've worked with any SQL Server type server, you'll have a great start. EXPLAINing MySQL Explain is the key tool to understanding the execution plan of the SQL operations. From the online help: With the help of EXPLAIN, you can see where you should add indexes to tables to get a faster SELECT that uses indexes to find rows. You can also use EXPLAIN to check whether the optimizer joins the tables in an optimal order. There's so much here, that it is impossible to go into every detail about how to use EXPLAIN to optimize operations. The great thing about MySQL is that there is so much help available from the MySQL folks and others around the world. That's the end of this EXPLAINation.

Using the wwsql class from West Wind to make things easier West Wind Web Connection is a great tool for all sorts of development efforts. I'm not a big fan of views, or cursoradapters in VFP development. I prefer the rough and tumble SQL Pass Through (SPT) method of manipulating data. The wwsql class helps take the pain out of SPT for me. There are two methods in particular that really help: SQLBuildInsertStatementFromObject and SQLBuildUpdateStatementFrom Object. These methods accept an object as the first parameter, and the name of the target table as the second parameter, and creates a string containing a valid INSERT or UPDATE command matching the contents of the object. There is a problem however. West Wind targets these methods at either VFP tables or SQL Server tables. There are some differences between SQL Server INSERT statements and MySQL INSERT statements. I probably haven't found all of the differences, but the changes are minor. The big difference is the representation of the empty date. In SQL Server, the empty date can be represented by the empty string. In MySQL, the empty date is represented by a series of zeros in the format of '0000 00 00'. West Wind also wraps field names in square brackets to help avoid problems with spaces in field names, and also to avoid problems with reserve words. In MySQL, fields wrapped in square brackets throws an error. So, I have subclassed the wwsql class and created three new properties: cemptydate, cfieldparamleft, and cfieldparamright. When in use against a MySQL table, I have populated cemptydate with the zero formatted string as above, and set the cfieldparamleft and cfieldparamright with the empty string as well. I then overrode the SQLBuildInsertStatementFromObject and the SQLBuildUpdateStatementFromObject to draw from these properties and it works like a charm. As a side note, I have also created a function named DtoMySQLDate( todate AS Date) function that returns a date formatted as '2007 06 20' no matter what SET DATE is set to.

I hope that you have gotten some tips in how to get VFP to access a MySQL server. Once you try it, I think you will find it a fast, robust, and inexpensive alternative to other solutions. Kevin