Questions tagged [dbix-class]

DBIx::Class is a Perl object-relational mapping (ORM) module. It aims to make representing queries in your code as perl-ish as possible while still providing access to as many of the capabilities of the database as possible, including retrieving related records from multiple tables in a single query, JOIN, LEFT JOIN, COUNT, DISTINCT, GROUP BY, ORDER BY and HAVING support.

from the description on CPAN:

This is an SQL to OO mapper with an object API inspired by Class::DBI (with a compatibility layer as a springboard for porting) and a resultset API that allows abstract encapsulation of database operations. It aims to make representing queries in your code as perl-ish as possible while still providing access to as many of the capabilities of the database as possible, including retrieving related records from multiple tables in a single query, JOIN, LEFT JOIN, COUNT, DISTINCT, GROUP BY, ORDER BY and HAVING support.

DBIx::Class can handle multi-column primary and foreign keys, complex queries and database-level paging, and does its best to only query the database in order to return something you've directly asked for. If a resultset is used as an iterator it only fetches rows off the statement handle as requested in order to minimise memory usage. It has auto-increment support for SQLite, MySQL, PostgreSQL, Oracle, SQL Server and DB2 and is known to be used in production on at least the first four, and is fork- and thread-safe out of the box (although your DBD may not be).

377 questions
6
votes
2 answers

How to properly use UTF-8-encoded data from Schema inside Catalyst app?

Data defined inside Catalyst app or in templates has correct encoding and is diplayed well, but from database everything non-Latin1 is converted to ?. I suppose problem should be in model class, which is such: use strict; use base…
w.k
  • 8,218
  • 4
  • 32
  • 55
6
votes
4 answers

How does DBIx::Class handle boolean values?

I'm using DBIx::Class in my perl script to interact with a sqlite database. When doing inserts/searches, what will DBIx::Class consider 'true' and 'false'? eg: $schema->resultset('SomeObject')->create({ some_boolean => 1, primary_key => 1…
Blaskovicz
  • 6,122
  • 7
  • 41
  • 50
6
votes
1 answer

How do I get the value of a foreign key rather than the object?

I've got two tables, book and language; book belongs_to language by having a language column stating which language it's in. The language table is just the language column. I want to do $book->language and get the language string, without fetching…
Jon
  • 188
  • 1
  • 8
5
votes
3 answers

Which Perl module should I use to generate a validating CRUD webform?

Has anyone successfully used something like DBIx::Class::WebForm or CatalystX-CRUD to automagically build a self-validating webform from a database table? I'm imagining a module that reads a database table schema, reads the constraints for each…
Will Sheppard
  • 3,272
  • 2
  • 31
  • 41
5
votes
2 answers

Can DBIx::Class be used with stored procedures instead of tables?

The access to read from the db has been given to me via mssql stored procedures that return result sets rather than tables or views. But I want to be able to read the data using ORM. I tried to use DBIx::Class::ResultSource::View to do the procedure…
stevenl
  • 6,736
  • 26
  • 33
5
votes
1 answer

Is there a way to connect to a DBIx::Class schema using an existing DBI database handle?

If I already have an active DBI database handle, is there a way to instantiate a DBIx::Class schema using that database handle, rather than creating a new connection, e.g. something like my $schema = MyApp::Schema->connect($dbh); (This is because…
Rob
  • 781
  • 5
  • 19
5
votes
1 answer

DBIx::Class::ResultSet Update or Create on multiple unique constraints

I was wondering if it is possible update_or_create on multiple unique constraints in dbix Ex From Cpan: my $cd = $schema->resultset('CD')->update_or_create( { artist => 'Massive Attack', title => 'Mezzanine', year => 1998, …
shaneburgess
  • 15,702
  • 15
  • 47
  • 66
5
votes
1 answer

Cannot create non-virtual view using DBIx::Class::Schema::Versioned

I'm using DBIx::Class::Schema::Versioned and I want to create a new view as a table in the database. Setting __PACKAGE__->result_source_instance->is_virtual(1); makes correct use of the view definition from the schema (not creating the table), but…
Bianca
  • 322
  • 1
  • 10
5
votes
2 answers

How do I load fixtures correctly for a test suite using Test::DBIx::Class?

I have a bunch of tests for my DBIx::Class schema and I am using Test::DBIx::Class. This is great as it gives me useful test functions and loads fixtures. It also has a Test::mysqld trait so I can dynamically create a test mysqld instance, deploy…
cubabit
  • 2,527
  • 3
  • 21
  • 34
5
votes
1 answer

Inserting several "new" items into the database with DBIC

I'm working in a bioinformatics project that requires me to read genomic data (nothing too fancy, just think of it as strings) from various organisms and insert it into a database. Each read belongs to one organism, and can contain from 5000 to…
Leitouran
  • 578
  • 3
  • 16
5
votes
2 answers

How to define and use many_to_many relationships in DBIx::Class?

I have 3 tables in DB, simplified as that: book book_language language ===== <->> ============== <<-> ======== bookID book_languageID languageID title bookID language languageID With…
w.k
  • 8,218
  • 4
  • 32
  • 55
5
votes
1 answer

DBIx::Class::ResultSet problems

I've got the following code: package MyPackage::ResultSet::Case; use base 'DBIx::Class::ResultSet'; sub cases_last_fourteen_days { my ($self, $username) = @_; return $self->search({ username => $username, …
H.A
  • 53
  • 3
5
votes
1 answer

How to use the dbicdump to only dump specific table

I just need to dump specific tables from my database such that these specific tables (3 tables to be exact out of 200 tables) will now be implemented by DBIx::Class::Schema. Here is the command from the docs (https://metacpan.org/pod/dbicdump):…
Cadz
  • 139
  • 3
  • 21
5
votes
1 answer

Can Perl DBIx::Class override the way a column is retrieved from the database?

I have never used DBIx::Class until today, so I'm completely new at it. I'm not sure if this is possible or not, but basically I have a table in my SQLite database that has a timestamp column in it. The default value for the timestamp column is…
BrianH
  • 7,932
  • 10
  • 50
  • 71
5
votes
1 answer

Catalyst & Perl - Generate models in runtime

I'm working on an application that will generate database tables on runtime. I'm using Catalyst with DBIC and I need that when a new table is generated a new ResultSet is generated. This new ResultSet has to be added as a Catalyst Model so I can…
Wang
  • 51
  • 2
1 2
3
25 26