The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Biblio::Zotero::DB - helper module to access the Zotero SQLite database

VERSION

version 0.004

SYNOPSIS

  my $db = Biblio::Zotero::DB->new( profile_name => 'abc123.default' );
  $db->schema->resultset('Item')->all;

ATTRIBUTES

schema

A DBIx::Class schema that is connected to the zotero.sqlite file.

This can be cleared using clear_schema.

db_file

A string that contains the filename of the zotero.sqlite file. The default is located in the directory of "profile_directory" attribute.

storage_directory

A string that contains the directory where the Zotero attachments are located. The default is the storage subdirectory of the "profile_directory" directory.

profile_directory

A string that contains the directory where the zotero.sqlite database is located,

  $db->profile_directory( "$ENV{HOME}/.zotero/zotero/abc123.default/zotero/" );

profile_name

A string containing the profile name to use. Setting this will set the "profile_directory" attribute.

  $db->profile_name( 'abc123.default' );
  # corresponds to a profile directory such as
  # <~/.zotero/zotero/abc123.default/zotero/>

METHODS

find_profile_directories()

Returns an arrayref of the possible profile directories that contain a Zotero SQLite database. This can be used as a class method.

see: http://www.zotero.org/support/zotero_data

  Biblio::Zotero::DB->find_profile_directories()
  # returns:
  # [
  #   "$ENV{HOME}/.zotero/zotero/abc123.default/zotero",
  #   "$ENV{HOME}/.zotero/zotero/def567.default/zotero"
  # ]

EXAMPLE

  use Biblio::Zotero::DB;
  use List::UtilsBy qw(min_by);

  # find the most recently modified
  my $newest = min_by { -M } @{Biblio::Zotero::DB->find_profile_directories};
  my $db = Biblio::Zotero::DB->new( profile_directory => $newest  );

  # if there is an issue with the database lock here,
  # see L<Biblio::Zotero::DB::Role::CopyDB>
  $db->schema->resultset('Item')->all;

SEE ALSO

AUTHOR

Zakariyya Mughal <zmughal@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Zakariyya Mughal.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.