Re: DBIx::DBH - Perl extension for simplifying database connections

2004-12-09 Thread Peter J. Holzer
On 2004-12-07 22:36:58 -0800, Jonathan Leffler wrote:
 ConnectionStrings.com - Forgot that connection string? You will ...
 www.connectionstrings.com - All connection strings in one place! Here
 you'll find the syntax for ...
 
 
 It seems like someone else has already done it :-)
 
 (No, I didn't visit the site.)

The connection strings there are for ODBC, OLE and .NET. No DBI
connection strings, AFAICS.

hp

-- 
   _  | Peter J. Holzer  | If the code is old but the problem is new
|_|_) | Sysadmin WSR / LUGA  | then the code probably isn't the problem.
| |   | [EMAIL PROTECTED]|
__/   | http://www.hjp.at/   | -- Tim Bunce on dbi-users, 2004-11-05


pgpqiTPkqt3d2.pgp
Description: PGP signature


Re: Another db schema drawing tool: Dico and Druid

2004-12-09 Thread Ron Savage
Hi Folks

New ones: Dico and Druid. Both require Java.

http://savage.net.au/Ron//html/drawing-tools.html

--
Cheers
Ron Savage, [EMAIL PROTECTED] on 9/12/2004
http://savage.net.au/index.html



Re: DBIx::DBH - Perl extension for simplifying database connectio ns

2004-12-09 Thread Peter J. Holzer
On 2004-12-07 19:34:42 -0500, Christopher Hicks wrote:
 On Wed, 8 Dec 2004, Andy Hassall wrote:
 The fact still remains that the generic Host slot could
 be used for this purpose quite easily, as could the DB slot.
 
 I really really object to the DB slot being called DB.  Oracle's term
 tablespace is much less overused and confusing than database.
 
 But Oracle tablespaces have nothing to do with connecting; they're 
 logical pools of storage only, and they play no part in name resolution. 
 You can't specify a tablespace when connecting, you connect to an 
 instance of a database, and you specify a user to authenticate as, which 
 then determines which schema unqualified names refer to (by default).
 
 I'm talking about for the generic framework.  When you connect to PG or 
 MySQL you connect to a database within an instance.  Using the word 
 database there is confusing because database is such an abused term. 
 Since tablespace is a clear term that means what MySQL calls a database I 
 advocate using the less ambigous term.

I don't think MySQL databases and Oracle tablespaces are similar. There
is more similarity between MySQL databases and Oracle schemas (but not a
1:1 correspondence, either).


 So using tablespace in a DSN for Oracle would itself be confusing.
 
 So what?  If its superfulous for Oracle so be it. 

Its not superfluous, its something different. Why use a term from one
RDBMS to to designate something in another database, which a) is
conceptually very different and b) already has another name? This way
you will confuse both MySQL users (who don't know what a tablespace is)
and Oracle users (who know what a tablespace is, but expect something
else).

hp

-- 
   _  | Peter J. Holzer  | If the code is old but the problem is new
|_|_) | Sysadmin WSR / LUGA  | then the code probably isn't the problem.
| |   | [EMAIL PROTECTED]|
__/   | http://www.hjp.at/   | -- Tim Bunce on dbi-users, 2004-11-05


pgpqKXxgHzDAb.pgp
Description: PGP signature


Re: Oracle Bulk Bind / Execute_Array

2004-12-09 Thread Tim Bunce
On Wed, Dec 08, 2004 at 11:50:02AM -0500, Kieran Hagzan wrote:
 Hello,
 
  I am sure this question has come up hundreds of times, but I must ask it 
 again:
 
 Are bind_param_array() and array_execute() fully implemented in the 
 DBD::Oracle driver?? 

No. I've had offers of patches but nothing actually provided and
too little time to do it myself.

 If they are, is there any known reference/examples of usage beyond the 
 DBD/DBI docs??

At least DBD::ODBC supports it. Not sure of any others.

 For the life of me, I cannot get bulk insertion to work :-(

Even if the driver doesn't support it, the DBI provides a fall-back
implementation that works - allbeit more slowly.

Tim.


Re: DBIx::DBH - Perl extension for simplifying database connectio ns

2004-12-09 Thread Peter J. Holzer
On 2004-12-08 10:21:35 +1300, Sam Vilain wrote:
 Orton, Yves wrote:
 DBD::Ingres does something similar. DBD::Oracle appears to be closer to
 Sybase/MySQl:
 dbi:Oracle:host=myhost.com;sid=ORCL
 
 Normally you don't bother with connection parameters with Oracle at all:
 
   DBI-connect(dbi:Oracle:, database, password);
 
 Instead, you configure which logical Oracle installation that you want
 with an environment variable.

For some values of normally. I don't do that, because I have different
perl scripts which connect to different databases. Having change the
TWO_TASK variable before invoking these scripts would be a major hassle.
Also some of of my scripts connect to several databases. 

 I think that this information should be removed from most programs
 altogether. 

Agreed.

 They should just have to specify a logical data source
 (possibly including a schema version), then a module with a config file
 maps that to a set of connection parameters.

That's what I do. 

Here is a snippet from one of my programs:

=head2 new(%opts)

Create a new UsrAdm object (basically a handle for the database
connection).

[...]

Options:

=over

=item credential_file

The file containing the credentials for connecting to the database. It
can be an absolute path name or relative to ~/.dbi. If it is not set,
the environment variable DBI_CREDENTIAL_FILE is used instead, or
~/.dbi/default, if that isn't set either. The file should contain a
single line with the data source, the username and the authentication
data (password) separated by white space.

=back

=cut

sub new {
my ($class, %opts) = @_;
my $self = {};

my $cred_file = $opts{credential_file} || $ENV{DBI_CREDENTIAL_FILE};
if (! defined($cred_file)) {
$cred_file = $ENV{HOME}/.dbi/default;
} elsif ($cred_file !~ m{/}) {
$cred_file = $ENV{HOME}/.dbi/$cred_file;
}

$self-{dbh} = DBI-connect(_read_cred($cred_file),
   { RaiseError = 1, AutoCommit = 0 });


hp

-- 
   _  | Peter J. Holzer  | If the code is old but the problem is new
|_|_) | Sysadmin WSR / LUGA  | then the code probably isn't the problem.
| |   | [EMAIL PROTECTED]|
__/   | http://www.hjp.at/   | -- Tim Bunce on dbi-users, 2004-11-05


pgpqZzy3WZa2i.pgp
Description: PGP signature


Re: DBD::Informix and Apache::Session

2004-12-09 Thread Tielman De Villiers
On Thu, 2004-12-09 at 07:25 +, Jonathan Leffler wrote:
 On Wed, 08 Dec 2004 16:18:06 +, Tielman de Villiers 
 [EMAIL PROTECTED] wrote: 
  I am trying to use Informix with Apache::Session, but keep on
 getting 
  problems. 
  This is the error in my apache log file: 
   
  DBD::Informix::st fetchrow_arrayref failed: SQL: -1820: Host
 variable 
  type has been changed between fetches or puts. 
  at /usr/lib/perl5/site_perl/5.6.1/Apache/Session/Store/Informix.pm
 line 
  78.
 
 I've looked at this - it is not obvious how that problem arises.
 Line 
 78 is indeed a fetchrow_arrayref call.
 
  I am testing this Apache::Session::Informix in a mod_perl
 environment 
  with HTML::Mason, but I doubt if the Mason/mod_perl part has
 anything 
  to do with the error, as the same perlhandler works fine when using 
  Postgresql.
 
 The error is odd - generated by IDS rather than DBD::Informix.
 
 Any chance of seeing your working code.  The longer 'finderr' message 
 did not help me much.
 

Of course, here is a snip from httpd.conf:

___START___

VirtualHost *:81
  ServerName krusty.xxx.com
  ServerAlias krusty
  PerlRequire  /opt/apache/conf/mason_handler.pl
  PerlSetVar site krusty
  DefaultType text/html
  DirectoryIndex index.cgi index.html
  CustomLog /opt/apache/log/krusty-access.log combined
  ErrorLog /opt/apache/log/krusty-error.log
  DocumentRoot /opt/apache/krusty/templates
  Directory /opt/apache/krusty/templates
  Options All MultiViews
  /Directory
  Alias /css/ /opt/apache/krusty/css/
  Alias /images/  /opt/apache/krusty/images/
  Location /
SetHandler perl-script
PerlHandler Mason::Krusty
  /Location
  Location /css
SetHandler default-handler
  /Location
  Location /images
SetHandler default-handler
  /Location
/VirtualHost

___END___

And here is mason_handler.pl:

___START___

#!/usr/bin/perl -w

package Mason::Krusty;
use HTML::Mason::ApacheHandler;
use strict;
use POSIX qw(strftime);

{   package HTML::Mason::Commands;
use vars qw(%session $dbh);
use Apache::Session::Informix;
##use Apache::DBI;
use DBI;
use CGI;
use POSIX qw(strftime);
use Date::Calc qw(:all);
use Date::Calendar::Profiles qw( $Profiles Next_Monday);

}

my $ah = HTML::Mason::ApacheHandler-new(
comp_root   = '/opt/apache/krusty',
data_dir= '/opt/apache/cache/krusty',
);

sub handler {
local *HTML::Mason::Commands::session;
my $r = shift;
return -1 if $r-content_type  $r-content_type !~ m|^text/|io;

my $cookie  = $r-header_in('Cookie');
$cookie =~ s/SESSION_ID=(\w*)/$1/ if $cookie;

eval {
tie %HTML::Mason::Commands::session,'Apache::Session::Informix',
$cookie,{
DataSource = 'dbi:Informix:[EMAIL PROTECTED]',
UserName   = 'xxx',
Password   = 'xxx',
Commit = 1
};
};
if ( $@ ) {
if ( $@ =~ /Object does not exist in the data store/  defined
$cookie ) {
tie %
HTML::Mason::Commands::session,'Apache::Session::Informix',undef,{
DataSource = 'dbi:Informix:[EMAIL PROTECTED]',
UserName   = 'xxx',
Password   = 'xxx',
Commit = 1
};
undef $cookie;
} else {
warn [, sprintf( strftime %Y-%m-%d %H:%M:%S ,
localtime ) ,] [WARN] $@;
}
}

unless ( $cookie ) {
my $scookie = SESSION_ID=$HTML::Mason::Commands::session
{_session_id};;
$r-header_out(Set-Cookie = $scookie);
}

my $status = $ah-handle_request($r);
$HTML::Mason::Commands::session{_last_time} = sprintf( strftime %Y-
%m-%d %H:%M:%S , localtime );
untie %HTML::Mason::Commands::session;

return $status;

}
1;

___END___




**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**



RE: Oracle Bulk Bind / Execute_Array

2004-12-09 Thread Jeff Urlwin
 
 At least DBD::ODBC supports it. Not sure of any others.

Er, ummm, not yet.

Jeff



RE: MySQL 4.1.7 req'd DBD Version

2004-12-09 Thread Mike Garner
-Original Message-
From: Rudy Lippan [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, December 08, 2004 6:05 PM
To: Mike Garner
Cc: [EMAIL PROTECTED]
Subject: Re: MySQL 4.1.7 req'd DBD Version

On Wed, 8 Dec 2004, Mike Garner wrote:

 Hello all-
 
 No doubt this question has been asked but I'm mailing to this last as a
last
 resort after nearly a full day of google searching for the results as I
hate
 asking questions that seem so clear on FAQ, list archives, etc. Alas, I
 couldn't find a clear answer.
  
 I've got a MySQL server running ver 4.1.7 with the new password hashing
 protocol and I'd like to connect with PERL. I'm running on Windows (I
know,
 I know), ActiveState 5.8.4.810 with DBI version 1.46 and DBD-MySQL 2.9004
 (thanks to Randy Kobes http://theoryx5.uwinnipeg.ca/ppms/DBD-mysql.ppd )
  
 But I'm still getting the error about the Client not supporting the
 authentication method required by the server when I connect. If I reset
the
 MySQL user account's password with old_password it'll connect fine. So my
 questions are:
 
  
 
 1) Assuming the new password hashing in MySQL 4.1.7, what's the minimum
DBI
 and DBD-MySQL version to connect?

You need at least DBD::mysql 2.9004 to compile against the 4.1.7 mysql
client 
libararies.  As for the password hashing, that is handled by the mysql
client 
libraries and not DBD::mysql. I don't know about windows, but under most
unixes 
this is just a simple matter of recompiling against the 4.1.7.

If I have DBD::mysql 2.9004 from Randy's site, as I mentioned above, when
then am I still receiving the client authentication protocol error?  Being
on Windoze, I'm not compiling the module myself. Is it possible that this
module is the current version but wasn't compiled against 4.1.7 libraries?
Does anyone know for sure about Randy's module or any other PPM module
available for an ActiveState PERL port that IS compiled against 4.1.7?




 4) Or is the only way to accomplish this is using old_password on the
MySQL
 side until the DBD/DBI gets caught up?
 

It is until you get a version compiled against the new libraries.

Rudy.





Re: Oracle Bulk Bind / Execute_Array

2004-12-09 Thread Tim Bunce
On Thu, Dec 09, 2004 at 10:07:37AM -0500, Jeff Urlwin wrote:
  
  At least DBD::ODBC supports it. Not sure of any others.
 
 Er, ummm, not yet.

Uh. Oh well.

Tim.

p.s. You forgot to say Patches Welcome :)


Re: Oracle Bulk Bind / Execute_Array

2004-12-09 Thread Ron Savage
On Thu, 9 Dec 2004 09:50:14 +, Tim Bunce wrote:

Hi Folks

 Are bind_param_array() and array_execute() fully implemented in
 the DBD::Oracle driver??

Lateral thinking suggests you might try generating a data file and using 
Oracle's bulk load facility to read that quickly...
--
Cheers
Ron Savage, [EMAIL PROTECTED] on 10/12/2004
http://savage.net.au/index.html



how can I extract String as UTF-8 under UNIX, my data was in SQL Server Database and stored as Unicode data

2004-12-09 Thread Yonghui Wang
when I simply use perl DBI, DBD::ODBC to connect to the database and try to 
extract the Unicode string( 
there is Chinese, Japanese, Korea) string stored in it, the return value is 
unreadable. I wish to get UTF-8 string so that those 
double byte language can be readable.

so, what configuration I need to do to the DBI, ODBC ?

thanks

hugh wang

CM Engineer
MicroStrategy Inc.

RE: how can I extract String as UTF-8 under UNIX, my data was in SQL Server Database and stored as Unicode data

2004-12-09 Thread Jeff Urlwin
DBD::ODBC has not even been tested with UTF-8 data.  

Patches/tests most welcome!!

Regards,

Jeff



 -Original Message-
 From: Yonghui Wang [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, December 09, 2004 4:09 PM
 To: [EMAIL PROTECTED]
 Subject: how can I extract String as UTF-8 under UNIX, my 
 data was in SQL Server Database and stored as Unicode data
 
 
 when I simply use perl DBI, DBD::ODBC to connect to the 
 database and try to extract the Unicode string( 
 there is Chinese, Japanese, Korea) string stored in it, the 
 return value is unreadable. I wish to get UTF-8 string so that those 
 double byte language can be readable.
 
 so, what configuration I need to do to the DBI, ODBC ?
 
 thanks
 
 hugh wang
 
 CM Engineer
 MicroStrategy Inc.
 



Low reactivity in the update of ActivePerl ?

2004-12-09 Thread St�phane Lepolozec
Want excuse me for the brutal manner to say the things but it seems me to 
notice a rather low reactivity in the update of ActivePerl since the 
absorption of ActiveState by Sophos. A certain number of modules are not up 
to date any more and not the least as DBD::MySQL which remains blocked with 
version 2.9003 (26 oct 2003) on PPMPackages/zips/8xx-builds-only/Windows/ 
(ASPN) whereas one finds the v2.9004 (13 jul 2004) on 
http://search.cpan.org/~rudy/DBD-mysql-2.9004/ (CPAN) - version necessary to 
exploit MySQL v4.1.7 fully (new system of coding of the passwords).

A new version of ActivePerl it is planned soon, very soon? 
ActivePerl-5.8.4.810-MSWin32-x86 dates from June 17, 2004 and one new 
version v5.8.6 is available since November 27, 2004; the 5.8.5 is since July 
19, 2004...

Does it act of a change of policy ?
If such is the case, that is regrettable bus ActivePerl is the best 
distribution for Windows...

Regards 




Low reactivity in the update of ActivePerl ?

2004-12-09 Thread St�phane Lepolozec
Want excuse me for the brutal manner to say the things but it seems me to
notice a rather low reactivity in the update of ActivePerl since the
absorption of ActiveState by Sophos. A certain number of modules are not up
to date any more and not the least as DBD::MySQL which remains blocked with
version 2.9003 (26 oct 2003) on PPMPackages/zips/8xx-builds-only/Windows/
(ASPN) whereas one finds the v2.9004 (13 jul 2004) on
http://search.cpan.org/~rudy/DBD-mysql-2.9004/ (CPAN) - version necessary to
exploit MySQL v4.1.7 fully (new system of coding of the passwords).

A new version of ActivePerl it is planned soon, very soon?
ActivePerl-5.8.4.810-MSWin32-x86 dates from June 17, 2004 and one new
version v5.8.6 is available since November 27, 2004; the 5.8.5 is since July
19, 2004...

Does it act of a change of policy ?
If such is the case, that is regrettable bus ActivePerl is the best
distribution for Windows...

Regards





Re: Does DBD::Sybase support a way to get the number of rows affected by a statement?

2004-12-09 Thread Matthew Persico
Check the DBI docs -  I seem to remember a generic function to call
for all DBDs which should be implemented to work for particular DBDs


On Thu, 9 Dec 2004 14:03:57 -0800 (PST), David Goodman
[EMAIL PROTECTED] wrote:
 I checked that DBD::Sybase documentation and did not
 find a way to get the number of rows affected by the
 previous statement.
 
 Is there an equivalent for ct_res_info()? Or is select
 @@rowcount the only way to do it?
 
 regards,
 
 David
 


-- 
Matthew O. Persico


DBD::mysql on OSX

2004-12-09 Thread Robert
Are there any gotchas for installing it?

Robert



Re: Does DBD::Sybase support a way to get the number of rows affected by a statement?

2004-12-09 Thread Chuck Fox
But for DBD::Sybase and most others it only tells you after you have 
fetched/processed the whole result set. 


Matthew Persico wrote on 12/9/2004, 7:56 PM:
 Check the DBI docs -  I seem to remember a generic function to call 
 for all DBDs which should be implemented to work for particular DBDs 
 
 
 On Thu, 9 Dec 2004 14:03:57 -0800 (PST), David Goodman 
 [EMAIL PROTECTED] wrote: 
  I checked that DBD::Sybase documentation and did not 
  find a way to get the number of rows affected by the 
  previous statement. 
  
  Is there an equivalent for ct_res_info()? Or is select 
  @@rowcount the only way to do it? 
  
  regards, 
  
  David 
  
 
 
 -- 
 Matthew O. Persico 

-- 
Your Friendly Neighborhood DBA,

Chuck 


Re: Does DBD::Sybase support a way to get the number of rows affected by a statement?

2004-12-09 Thread Matthew Persico
True.  You might as well just count along as you fetch. If you do() an
insert/update or delete, the return value from the do is the number of
rows (OEO on none, undef on error?)


On Thu, 9 Dec 2004 20:45:20 -0500, Chuck Fox [EMAIL PROTECTED] wrote:
 But for DBD::Sybase and most others it only tells you after you have 
 fetched/processed the whole result set.
 
 Matthew Persico wrote on 12/9/2004, 7:56 PM:
 
 
  Check the DBI docs -  I seem to remember a generic function to call
  for all DBDs which should be implemented to work for particular DBDs
 
 
  On Thu, 9 Dec 2004 14:03:57 -0800 (PST), David Goodman
  [EMAIL PROTECTED] wrote:
   I checked that DBD::Sybase documentation and did not
   find a way to get the number of rows affected by the
   previous statement.
  
   Is there an equivalent for ct_res_info()? Or is select
   @@rowcount the only way to do it?
  
   regards,
  
   David
  
 
 
  --
  Matthew O. Persico
 
 --
 Your Friendly Neighborhood DBA,
 
 Chuck
 


-- 
Matthew O. Persico


Re: Does DBD::Sybase support a way to get the number of rows affected by a statement?

2004-12-09 Thread Michael Peppler
On Thu, 2004-12-09 at 23:03, David Goodman wrote:
 I checked that DBD::Sybase documentation and did not
 find a way to get the number of rows affected by the
 previous statement. 
 
 Is there an equivalent for ct_res_info()? Or is select
 @@rowcount the only way to do it?

ct_res_info() (in C) will only return the number of rows returned by a
SELECT after all the rows have been fetched.

Same with SELECT @@rowcount (for obvious reasons - it's a bit hard to
run SELECT @@rowcount *before* the SELECT data... :-)

So DBD::Sybase's $sth-rows implementation will return valid data for
SELECT statements right after the last row has been fetched.

$sth-rows will return correct data immediately after execute() for
INSERT/UPDATE/DELETE statements.

Michael
-- 
Michael Peppler  -  [EMAIL PROTECTED]  -  http://www.peppler.org/
Sybase DBA/Developer
Available for contract work - http://www.peppler.org/resume.html