Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^3: I got confuse with INSERT

by grep (Monsignor)
on Mar 17, 2008 at 20:41 UTC ( #674639=note: print w/replies, xml ) Need Help??

in reply to Re^2: I got confuse with INSERT
in thread I got confuse with INSERT

There is a not a (practical) programmatic way to speed up that code (without knowing more). But I think you are heading down to XY_problem Territory.

Can you give a clearer spec of what you are really trying to accomplish?
Because, I can almost guarantee that copying a set of data from one table to another is not the solution.

One dead unjugged rabbit fish later...

Replies are listed 'Best First'.
Re^4: I got confuse with INSERT
by padawan_linuxero (Scribe) on Mar 24, 2008 at 18:36 UTC
    yes is like this:
    We have a very obsolete program that runs on FoxPro for DOS
    but for a big reason ($$$$) we cant change it, our customers
    want to see the data send to us in a more easy way like a web page
    so I need to take the data from several DBF and turn them into MySQL tables to work with them the thing is that in the convertion is taking a lot of time, and the clients wants to see them in real time
    working with mysql is quite fast but when I need to do the part of bringing new data from dbf to mysql it take sometime like 7 minutes for one table (a small one) so imagine a big table with almost 3 times that size it takes forever.
    So I try to do it directly with DBF but it takes more time.

      I have been working with foxpro data lately and may be able to help you access and manipulate the data directly from the .dbf files. If you are on a windows machine you can connect using DBI with DBD::ADO module installed.

      FYI, my data is in individual dbf tables, not a unified foxpro database. Here is what I did:

      #!/usr/bin/perl -w use strict; use DBI; # requires installing perl module DBD::ADO # and microsoft ole db driver for foxpro - avialable from microsoft de +veloper website my $connect_string = 'Provider=VFPOLEDB.1;Data Source=C:\foxpro\folder +;Mode=ReadWrite|Share Deny None;Password="";Collating Sequence=MACHIN +E'; # ADO Connection String my $dbh = DBI->connect("dbi:ADO:$$connect_string") or die("Can't conne +ct: $DBI::errstr"); # note: haven't been able to figure out using placeholders yet, or if +it is even supported - i.e. "select * from table where id = ?" # table in this statement is your dbf file, i.e. table.dbf my $sth = $dbh->prepare("select * from table where date between {d '20 +08-08-01'} and {d '2008-08-16'} order by date") or die( "Database Err +or: $DBI::errstr" ); $sth->execute() or die( qq(Database Error: $DBI::errstr) ); while (my $r = $sth->fetchrow_hashref) { # do stuff with $r->{column_name}, etc. # helpful note: @{$r->{NAME}} works with foxpro/ado connection - g +ives you an array of the table column names } $sth = $dbh->prepare("insert into table (column1,column2,date) values +('Hi','There',{^2008-08-16})") or die( "Database Error: $DBI::errstr" + ); $sth->execute() or die( qq(Database Error: $DBI::errstr) ); # notice the difference in date formats for select and insert - took m +e a while to figure that out # if you have foxpro tables that rely on indexes, you can select just +fine # and you can insert, but I don't know how to update the index file # anyone else know? $sth->finish; $dbh->disconnect; exit;

      If anyone knows how to work with foxpro indexes, especially to update the index on an sql insert, that would be very helpful information for me.

      WinVista, ActivePerl 5.8.8, ActiveState Komodo IDE 4.0

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://674639]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2017-04-30 22:47 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (543 votes). Check out past polls.