This should be good enough as a basis for any port tool someone else may need to write.# Port from SQL Server to MySQL use strict; use warnings 'all'; use DBI; use DBD::mysql; use Win32::OLE; use constant adOpenKeySet => 1; my $db_datasource = 'driver={SQL Server};Server=HOST; database=DB;uid= +UID;pwd=PWD;'; my $db_connection = new Win32::OLE('ADODB.Connection'); $db_connection->Open($db_datasource); my $dsn = "DBI:mysql:database=DB;host=HOSTNAME"; my $my_sql = DBI->connect($dsn, 'me', 'julie', {RaiseError=>1}); # notice use of RaiseError - goodbye DBI::errstr! my $table = 'OTHER_TABLE'; my @field = qw(ID description file_data); my $rs = new Win32::OLE("ADODB.Recordset"); $rs->Open("SELECT * FROM $table", $db_connection, adOpenKeySet); # Prepare our insert my $insert_sql = "INSERT INTO $table (" . join(',',@field) . ') VALUES (' . join(',',map '?',@field) . ')' ; my $sth = $my_sql->prepare($insert_sql); while (!$rs->EOF) { $sth->execute( map $rs->{$_}{Value}, @field ); $rs->MoveNext(); } $rs->close(); $db_connection->close(); $my_sql->disconnect();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Porting from SQL Server to MySQL
by jeffa (Bishop) on Aug 11, 2003 at 15:53 UTC | |
|
Re: Porting from SQL Server to MySQL
by Anonymous Monk on Aug 11, 2003 at 14:36 UTC | |
by simon.proctor (Vicar) on Aug 11, 2003 at 15:19 UTC |