简体   繁体   English

序列化和反序列化perl DBI连接对象

[英]Serialize and deserialize perl DBI connection object

I need serialize one array with DBI connection objects to shared with others process using shared memory. 我需要使用DBI连接对象序列化一个数组,以便使用共享内存与其他进程共享。 But deserialize not working. 但是反序列化不起作用。

use storable qw/freeze thaw/; 使用可储藏的qw /冻融液/;

my @connections;

for(my $c = 0;$c < 5;$c++) {
  my $conn = DBI->connect($dsn,$user,$password,{'AutoCommit' => 1, 'RaiseError' => 1, 'PrintError' => 0});
  push(@connections,$conn);
}

my $shm = freeze(@connections);
my $obj = thaw($shm);

Return error: Global symbol 返回错误:全局符号

"$drh" requires explicit package name (did you forget to declare "my $drh"?) at (eval 33) line 6. “ $ drh”要求在(eval 33)第6行中使用显式软件包名称(您是否忘了声明“ my $ drh”?)。

您无法序列化数据库句柄/连接,因为它由Storable无法访问的用户空间数据(即Perl外部和数据库库内部,也可能在TLS库中)以及内核数据(如文件描述符)组成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM