RE: visual foxpro 6 to mysql

Author: Gary Jeurink

Posted: 2011-08-10 at 17:23:36

Definitely along the lines that I want to pursue. I tried to generate the

text files described below and they were picky about how big they could be.

You are a little over my head but it gives me a place to try and learn to

connect directly from fox to mysql. 120 tms, o-rush, o-pass, o-pts then to

defense d-rush, d-pass, d-pts... and turnovers. I also have their rank in

each category so I do a power rating from that. Weakness is that teams that

play weenie schedules get inflated stats. I simply average the offense yd

stat of one team with the defense yds allowed stat of the other team...

simple but tedious to display

Thanks bunches, all of you

Gary Jeurink

-----Original Message-----

From: Graham Brown [mailto:info@compsys.co.uk]

Sent: Wednesday, August 10, 2011 6:29 AM

To: ProFox Email List

Subject: RE: visual foxpro 6 to mysql

Hi Gary

First of all download MyODBC from the MySQL website if not done already.

This will give you a new odbc driver in control panel.

The variables below for ipaddress, dbname, userid and password should all be

on PHPMyAdmin which is the way most hosting companies allow you to manage

MySQL. You may need to ask for the IP because it isn't always just an IP .

On one of my sites it is "cluster.mysqlinstance.domainname.com".

This fox code downloads from one of my databases.

nMySQL1=Sqlstringconnect("Driver={MySQL ODBC 5.1 Driver};

Server=<ipaddress>; Database=<dbname>; UID=<userid>; PWD=<pass>; Option=3")

If nMySQL1>=0

SQLEXEC(nMySQL1,"select * from tblagents","crs")

Select crs

Endif

SQLDISCONNECT(nMySQL1)

Once you have a handle to the database via Stringconnect you can fire any

SQL commands at it.

I sometimes have weird issues where commands do not complete. AsyncMode in

the properties usually fixes this.

SQLSETPROP(nMySQL, 'asynchronous', .F.)

UDL files are a good way to get at a connection string. If you haven't used

them before right click on your desktop/new/text doc. Rename this to .UDL

and run it.

You'll get the standard windows wizard. Fill in the blanks and test

connection. Rename back to .txt open it and there's your connstring.

If you can't connect remotely to the MySQL database another way is to FTP

the file and run a php webpage both via fox.

Google has lots of resources for parsing a csv in php. This is the page at

the top of the list

http://php.net/manual/en/function.fgetcsv.php

Cheers

Graham

-----Original Message-----

From: profox-bounces@leafe.com [mailto:profox-bounces@leafe.com] On Behalf

Of Gary Jeurink

Sent: 10 August 2011 04:31

To: GrahamB

Subject: RE: visual foxpro 6 to mysql

I'm not great at PHP but I'm learning. Tables are cTeams, cGames, cTmstats.

The cTmstats gets updated each week along with cGames that have been played.

I don't know how to update the MySQL cTmStats with the foxpro cTmstats.dbf

each Tuesday morning. I need to update the MySQL tables at godaddy with my

foxpro data and I don't know how. PHP gives me access to MySQL but how do I

connect foxpro? ... I tried delimited text but they usually crash at 1/2 to

2/3rds using MyAdmin... whatever its called.

Gary Jeurink

-----Original Message-----

From: Stephen Russell [mailto:srussell705@gmail.com]

Sent: Tuesday, August 09, 2011 6:07 PM

To: ProFox Email List

Subject: Re: visual foxpro 6 to mysql

On Tue, Aug 9, 2011 at 5:26 PM, Gary Jeurink <g.jeurink@charter.net> wrote:

> I have developed a football statistics database that I update each

> week

for

> the 120 d1a college football teams and the 32 pro teams. Included is

> the schedule so you can pick a game and the various yds and points are

predicted

> for upcoming games. Its fun  and I do well on college pickem and

> pigskin pickem on espn. I update from web pages to excel sheets and

> then merge to

my

> database with a view each week. What is the easiest way  to reload a

> MySQL table on a server [godaddy] from my foxpro data table?

>

-------------

I would do update statements as well as insert statements.

You can crunch many togther via a union and pass a long string as a script

So how do you set up to accomplish this? I would make two passes to

identify updates to existing rows and then add in new rows. Create a script

per table for both types of statements.

Just a guess but you have a row for each team in a game ? You also put in

some rows to support players accomplishments in that game?

Inserts are pretty simple :

INSERT INTO table1 (field1, field2)

VALUES ('foo', 'bar');

UPDATE table1 SET field1 = 'foobar', field2' = 'new value' where ID=???

--

Stephen Russell

Unified Health Services

60 Germantown Court

Suite 220

Cordova, TN 38018

Telephone: 888.510.2667

901.246-0159 cell

[excessive quoting removed by server]

_______________________________________________

Post Messages to: ProFox@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/profox

OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech

Searchable Archive: http://leafe.com/archives/search/profox

This message: http://leafe.com/archives/byMID/profox/5EB6DA7C8C3F4D2DA93C1DE32B92C775@OwnerPC

** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

©2011 Gary Jeurink