package SQLDB @ISA = qw() sub Quote my($this, $str, $sqlcharcode, $sourcecharcode) = ( return $str; return $str; return $str; return $s; return $str; sub MySQLQuote my($str, $sqlcharcode, $sourcecharcode) = ( return $str; sub GetDBDNameFromDBManagerName my ($ManagerName) = @_; return 'mysql'; return 'Pg'; return 'SQLite'; return 'CSV'; return 'Excel'; return 'Access'; return 'SQLServer'; return $ManagerName; my ($this, @a) = @_; return $this->App()->print(@a) if($this->App()); return $this->App()->print(@a); return print(@a); my ($this, @a) = @_; return 1 unless($this->Debug()); return $this->print(@a); my ($this) = @_; return $this->App()->Debug() if($this->App()); return $this->{'Debug'}; my ($this,$f) = @_; return $this->App()->SetDebug($f) if($this->App()); return $this->{'Debug'} = $f; sub SetSQLitePath sub SetSQLitePath { my ($this,$p)= return $this->{SQLitePath} = $p; sub SQLitePath return shift->{SQLitePath}; sub DBMName my ($this) = @_; return $this->{DBMName}; sub SetDBMName sub SetDBMName { my($this,$d)= return $this->{'DBMName'} = $d; sub db return shift->{'dbh'}; sub dbh return shift->{'dbh'}; sub sth return shift->{'sth'}; sub DBServer return shift->{'DBServer'}; sub DBName return shift->{'DBName'}; sub DBUser return shift->{'DBUser'}; sub DBPassword return shift->{'DBPassword'}; sub AutoIncrementColumn return shift->{AutoIncrementColumn}; sub SetAutoIncrementColumn my ($this, $column) = @_; return $this->{AutoIncrementColumn} = $column; sub DBCharCode return shift->{'DBCharCode'}; sub SetDBCharCode sub SetDBCharCode { my ($this,$c)= return shift->{DBCharCode} = $c; sub SourceCharCode return shift->{'SourceCharCode'}; sub SetSourceCharCode sub SetSourceCharCode { my ($this,$c)= return shift->{SourceCharCode} = $c; sub SetCharCodeConversion sub SetCharCodeConversion { my ($this,$f)= return shift->{CharCodeConversion} = $f; sub SetUseOriginalQuote sub SetUseOriginalQuote { my ($this,$f)= return shift->{UseOriginalQuote} = $f; sub ErrorNum return DBI::err; sub ErrorStr return DBI::errstr; sub nFields my ($this, $sth) = @_; return undef unless($sth); return $sth->{"NUM_OF_FIELDS"}; sub pFieldNames my ($this, $sth) = @_; return undef unless($sth); return $sth->{"NAME"}; sub GetHitDataNumber my ($this, $TableName, $condition) = @_; return $nHitData; sub new my ($module, $DBMName, $CharCode, $DBServer, $DBUser, $DBPassword, $DBName, $PrintDBIError, $PrintError) = @_; my $this = {}; bless $this; $this->Initialize(); $this->SetSQLitePath($SQLitePath); if($DBMName =~ /csv/i) { $this->{'DBMName'} = 'CSV'; } elsif($DBMName =~ /Excel/i) { $this->{'DBMName'} = 'Excel'; } elsif($DBMName =~ /(pg|postgre)/i) { $this->{'DBMName'} = 'Pg'; } elsif($DBMName =~ /mysql/i) { $this->{'DBMName'} = 'mysql'; } elsif($DBMName =~ /sql/i) { $this->{'DBMName'} = $DBMName; } elsif($DBMName =~ /Access/i) { $this->{'DBMName'} = 'Access'; } elsif($DBMName =~ /SQL.*Server/i) { $this->{'DBMName'} = 'SQLServer'; } else { print "Warning in SQLDB::new: [$DBMName] is not implemented.\n" if($PrintError); ($module, $CharCode, $DBServer, $DBUser, $DBPassword, $DBName, $PrintDBIError, $PrintError) = @_; return $this; sub DESTROY my $this = shift; sub Initialize my ($this) = @_; sub Open my ($this, $DBServer, $DBUser, $DBPassword, $DBName, $CharCode, $PrintDBIError, $PrintError) = @_; return; return undef; return ($this->{dbh}, undef) unless($DBName); return
\n"; return ($this->{dbh}, undef); return ($this->{dbh}) if($DBName eq ''); return ($this->{dbh}, $this->Use($DBName, $PrintError) ); sub Use my ($this, $DBName, $PrintError) = @_; return undef; return undef; return undef if(!$this->{dbh}); return undef; return undef; return $this->{DBsth}; sub CloseSTH my ($this, $sth) = @_; return; sub CloseDBH my ($this) = @_; sub Close my ($this) = @_; sub Prepare my ($this, $command, $UseNonDefSTH, $PrintError) = @_; return undef if(!$this->{'dbh'}); return undef; return $sth; sub Execute my ($this, $command, $UseNonDefSTH, $PrintError) = @_; return undef if(!$this->{'dbh'}); return undef; return undef; return ($this->{'sth'} = $sth, $ret); sub GetNextHit my ($this, $sth) = @_; return undef if(!defined $this); return undef if(!$sth); return %ret; sub nHit sub nHit { my ($this,$sth)= return $this->nHits($sth); sub nHits my ($this, $sth) = @_; return $this->{nHit}; sub rows my ($this, $sth) = @_; return undef unless($sth); return $sth->rows; sub fetchrow_array my ($this, $sth) = @_; return $sth->fetchrow_array; sub DeleteDatabase my ($this, $DBName) = @_; return undef unless($sth); return 1; sub DeleteTable my ($this, $DBName, $TableName, $IsPrint, $PrintError) = @_; return undef unless($sth); return undef unless($sth); return 1; sub GetDatabases my ($this) = @_; return @DBs; return ($this->{DBName}); return ($this->{DBName}); return (); return @DBs; sub CreateDatabase my ($this, $dbname) = @_; return Deps::CreateDirecotry($dbname) if($this->DBMName() =~ /^csv$/i); return 1; return $this->Execute($sql, 0, 1); sub DescribeTable my ($this, $tablename) = @_; return 1; return ($nHit, \@Keys, @lines); sub IsExistDatabase my ($this, $dbname) = @_; return -d $dbname if($this->DBMName() =~ /^csv$/i); return -e $dbname; return $dbh; return -1 if(@DBs == 0); return 1 if($dbname eq lc $DBs[$i]); return 0; sub GetTables my ($this, $DBName, $PrintError) = @_; return @a; return @tables; return @tables; return undef unless($sth); return @Tables; sub IsExistTable my ($this, $DBName, $TableName) = @_; return -e "$DBName/$TableName"; return 1 if(lc $TBLs[$i] eq $TableName); return 0; sub GetDrivers my ($this) = @_; return $this->GetDBManagers(); sub GetDBManagers my ($this) = @_; return DBI->available_drivers(); sub GetFieldTypes my ($this, $DBName, $TableName, $FieldName, $PrintError) = @_; return undef unless($sth); return @FieldTypes; sub GetStringType my ($this, $type) = @_; return $str; return 'SQL_CHAR'; return 'SQL_NUMERIC'; return 'SQL_DECIMAL'; return 'SQL_INTEGER'; return 'SQL_SMALLINT'; return 'SQL_FLOAT'; return 'SQL_DOUBLE'; return 'SQL_VARCHAR'; return 'unrecognized'; sub ExtractDBHash my ($this, $DBName, $TableName, $pParams) = @_; return \%DBHash; sub GetFields my ($this, $DBName, $TableName, $PrintError) = @_; return undef unless($sth); return @Fields; sub BuildDBHash my ($this, $pLabels, $pHash, $DBCharCode, $AddBlankData) = @_; return %d; sub BuildHash my ($this, $pLabels, $pData, $DBCharCode, $AddBlankData) = @_; return %d; sub GuessDatabaseDefinition my ($this, $filename, $nGuessLines, $IgnoreBlank, $DBCharCode, $SourceCharCode, $IsPrint) = @_; return undef; return @DataBaseDefinition; sub GetTableDefinition my ($this, $DBName, $TableName) = @_; return (-1) if(!$sth or !$ret); return @pDefs; sub CreateTable my ($this, $TableName, $pDefsHash) = @_; return 0; return ($sth, $ret); sub IsExistData my ($this, $TableName, $condition) = @_; return -1 if(!defined $TableName); return 0; return $nHit; sub JoinSearch my ($this, $TableName1, $TableName2, $JoinCondition, $condition, $fields) = @_; return undef if(!$this->Execute($sql0, 1, 1)); return $this->Execute($sql, 1, 1); sub Search my ($this, $TableName, $condition, $fields) = @_; return undef if(!$this->Execute($sql0, 1, 1)); return $this->Execute($sql, 1, 1); sub InsertData my ($this, $TableName, @a) = @_; return undef unless($sth); return 1; sub UpdateData my ($this, $TableName, $condition, @a) = @_; return undef unless($sth); return 1; sub DeleteData my ($this, $TableName, $condition) = @_; return undef unless($sth); return 1; sub UpdateDataByAutoJudge my ($this, $TableName, $condition, @a) = @_; return undef unless($sth); return 1; sub MakeUpdateCommand my $this = shift; my ($DBTableName, $charcode, $action, $condition, @a) = (@_); my $narg = @_; return ""; return ""; return $sql; sub SaveToCSV my ($this, $TableName, $condition, $fields, $path, $charcode, $pDeleteKeys) = @_; return 0 if(!$out->Open($path, "w", 0)); return 1; sub MakeCSVFile my ($this, $OutFilePath, $CSVFileCharCode, $DBTableName, $sql, %args) = @_; return 0; return $nHit; sub RestoreDBFromFile my ($this, $DBServer, $DBUser, $DBPassword, $File, $ShowMessage) = @_; sub MakeBackupFile my ($this, $DBServer, $DBName, $DBUser, $DBPassword, $File, $ShowMessage) = @_;