Friday, July 6, 2007

MySQLDump

How to duplicate/backup data between database both in one server or other server ?
Answer:
- Make sure that you have mysqladmin and mysqldump
- Do the Following script:
#Create the database on the destination server
mysqladmin -u YourUserDBDest -h YourDestServer --password=YourPasswDBDest create YourDBDest
#The Real Job Goes Here
mysqldump -u YourUserDBSource -h YourSourceServer --password=YourPasswDBsource YourSourceDB| mysql -u YourUserDBDest -h YourDestServer --password=YourPassDBDest YourDBDest


Here is an example (I use EasyPHP 2.0b1 for win) that I bundled in batch file:

cd\Program Files\EasyPHP 2.0b1\mysql\bin\
mysqladmin -u root -h Server2 --password=secret2 create db2
mysqldump -u root -h Server1 --password=secret1 db1 | mysql -u root -h Server2 --password=secret2 db2

Thursday, June 21, 2007

HTTP Post

Webbase application is good for any operation system,however, it's not simple to make it easy for bulk data manipulation. While, desktop application has it, easy for bulk data manipulation, user friendly and etc.
Why? Because desktop application, delphi for example, supported event driven, while webbase is not.
Now many webbase language, like php, combined with ajax can handle this, however, it's need huge of memory resources.

In order to solve this obstacle, delphi has already prepared. With IdHTTP (Indy component), we can manipulate web application through dekstop application.

The following is an example:

procedure TFHttpUpload.Upload;
var
Stream : TIdMultipartFormDataStream;
begin
Stream := TIdMultipartFormDataStream.Create;
try
StatusBar1.SimpleText:='Upload............';
Stream.AddFormField('ffield1','one');
Stream.AddFormField('ffield2','dua');
Stream.AddFile( 'fFile', fname, 'text/plain' );
str :=IdHTTP1.Post('http://www.myweb.com/upload.php', Stream );
ShowMessage('Upload Sucess :)');
except
ShowMessage('Upload Fail :(');
end;
Stream.Free;
end;