テーブル定義のexcelファイル出力(3)

id:smeghead:20070917:def2 の続きです。

最後です。

create_table_def.pl

#! c:/Perl/bin/perl
use strict;
use warnings;
use Getopt::Std;
 
use DbDefInfo;
use WriteExcelDbDefInfo;
 
my $usage = <<"USAGE";
USAGE: $0 -u <username> -p <passwd> [-h <hostname>] -d <dbname> -t <dbtype> [-o <output_file_name>] [-s <schema_name>]
create table definition excel file from database. postgresql only.
 <username>         connect user name.
 <passwd>           connect user password.
 <hostname>         connect server name.
 <dbname>           connect database name.
 <dbtype>           postgresql 'PgPP'
 <output_file_name> excel file name which will create.
 <schema_name>      schema name.
USAGE
 
our ($opt_u, $opt_p, $opt_d, $opt_h, $opt_o, $opt_s, $opt_t);
getopt('oupdhst');
unless ($opt_u && $opt_p && $opt_d && $opt_t) {
  print STDERR $usage;
  exit(1);
}
 
my $settings = {
  user => $opt_u,
  passwd => $opt_p,
  dbname => $opt_d,
  host => $opt_h || 'localhost',
  output => $opt_o || 'table_def.xls',
  schema_name => $opt_s || 'public',
  type => $opt_t
};
 
my @tables = get_table_def_infos($settings);
write_db_def_info(\@tables, $settings);

実行方法

$ ./create_table_def.pl -u username -p password -d dbname -h localhost -t PgPP

必須の引数がない場合に、usageを表示するようにしてます。

$ ./create_table_def.pl

突っ込み歓迎ですm(_ _)m

コメントする

メールアドレスが公開されることはありません。 が付いている欄は必須項目です


The reCAPTCHA verification period has expired. Please reload the page.

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください