Search code examples
perlperl-module

How to change database from MySQL to Oracle in TheSchwartz


I'd like to switch database from MySQL to Oracle in perl's TheSchwartz module which is the job queue system. I suspects following code has the key.

my $client = TheSchwartz->new(
    databases => [{
    dsn  => 'dbi:mysql:TheSchwartz',
    user => 'dbi',
    pass => 'xxxxxxx',
    }],
    verbose => 1,
);  

I changed the code.

dsn  => 'dbi:mysql:TheSchwartz',  

to

dsn  => 'dbi:Oracle:OraDB01',    

then I got the message.

#Disabling DB 9e410d44ac4b9ede28c9ef34f6c1e817 because unknown

TheSchwartz doesn't tell me any clue of Oracle's error(ex password error ,or network error ....).

My question are
1. Is it possible to use Oracle in perl's TheSchwartz?
2. For dubugging ,how to get the ORA- Error message in TheSchwartz?

Any help would be welcomed.
Regards,


Solution

  • Using TheSchwartz is almost certainly a complete red herring here. TheSchwartz is just creating a DBI connection. So once you can successfully create a DBI connection outside of TheSchwartz, you should be able to do the same insider TheSchwartz.

    The way I would approach it would be in two stages:

    • Write a simple DBI program to connect to the Oracle database.
    • Copy your successful connection details to your TheSchwartz code.

    The simple DBI program I'd write, only needs to be as simple as this:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    
    use DBI;
    
    my $dbh = DBI->connect('dbi:Oracle:OraDB01', 'dbi', 'xxx')
      or die $DBI::errstr;
    

    That will presumably fail in the same way as your existing code, but you'll get the raw DBI connection error which should allow you to work out what the problem is.

    Obviously, you might find the DBD::Oracle documentation to be useful as well.