[Dbix-class] Multiple connections

2014-01-16 Thread Dave Howorth
Is there a good (authoritative?) description of how DBIx::Class manages database connections? Including whatever is done by other packages underneath. I think I need to make two connections to the same MySQL database with different settings of the mysql_enable_utf8 option. But calling connection

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Hernan Lopes
i guess you are using catalyst dbix models. dont forget its perl, that means you can create an $app instance to be used by catalyst. Your models dont need and should not be tied to your web framework. what i am saying is, create Your::App module and make it connect to multiple databases. Create

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Dave Howorth
Hernan Lopes wrote: i guess you are using catalyst dbix models. No I'm not using Catalyst. I want to make two connections to the same database in the same application. My question was correct, I think. ___ List:

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Spevak, Martin (HPES Network Management Solutions)
I am not sure, if you need this, but try: -- [ run.pl ] - use Project::DBIx; use Project::Config qw/$config/; my $db1 = Project::DBIx-connect( $config-{'db'}-{'dbi_dsn'}, $config-{'db'}-{'username'}, $config-{'db'}-{'password'}, {AutoCommit = 1},

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Lianna Eeftinck
Just curious, why would you want to make two connections to the same database with only a difference in the mysql_enable_utf8 option? It is generally a bad idea to open more than one connection to a database because you might find updates in one are not showing up straight away in the other, such

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Will Crawford
Copy your lib/MyApp/Model/DB.pm (or whatever it's called), and in the second copy, add the mysql_enable_utf8 = 1 to __PACKAGE__-config( { ... } ); or add it in your myapp.conf under the new model name. On 16 January 2014 11:06, Dave Howorth dhowo...@mrc-lmb.cam.ac.uk wrote: Is there a good

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Peter Rabbitson
On Thu, Jan 16, 2014 at 11:06:14AM +, Dave Howorth wrote: I think I need to make two connections to the same MySQL database with different settings of the mysql_enable_utf8 option. But calling connection twice seems to result in a single connection. connection() is not a proper way to

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Dave Howorth
Peter Rabbitson wrote: On Thu, Jan 16, 2014 at 11:06:14AM +, Dave Howorth wrote: I think I need to make two connections to the same MySQL database with different settings of the mysql_enable_utf8 option. But calling connection twice seems to result in a single connection. connection()

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Dave Howorth
Lianna Eeftinck wrote: Just curious, why would you want to make two connections to the same database with only a difference in the mysql_enable_utf8 option? It is generally a bad idea to open more than one connection to a database because you might find updates in one are not showing up

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Lianna Eeftinck
I'm open to any suggestions, but for now it looks like the two-connection approach solves my problem. You never stated the problem you are trying to tackle with the two connections. :) On 16 January 2014 14:23, Dave Howorth dhowo...@mrc-lmb.cam.ac.uk wrote: Lianna Eeftinck wrote: Just

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Dave Howorth
Dave Howorth wrote: Peter Rabbitson wrote: On Thu, Jan 16, 2014 at 11:06:14AM +, Dave Howorth wrote: I think I need to make two connections to the same MySQL database with different settings of the mysql_enable_utf8 option. But calling connection twice seems to result in a single

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Dave Howorth
Lianna Eeftinck wrote: I'm open to any suggestions, but for now it looks like the two-connection approach solves my problem. You never stated the problem you are trying to tackle with the two connections. :) You're right. I want to read data from a MySQL database where some tables use

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Bill Moseley
On Thu, Jan 16, 2014 at 7:25 AM, Dave Howorth dhowo...@mrc-lmb.cam.ac.ukwrote: Lianna Eeftinck wrote: I'm open to any suggestions, but for now it looks like the two-connection approach solves my problem. You never stated the problem you are trying to tackle with the two connections. :)

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Lianna Eeftinck
Afaik, 'mysql_enable_utf8 = 1' (and there are similar options for Postgress and SQLite at least) just tells the mysql driver that if a column is marked as having a UTF8 charset in the table, it'll try to return the data as such. If your column has a different character set the option won't do

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Dave Howorth
Bill Moseley wrote: On Thu, Jan 16, 2014 at 7:25 AM, Dave Howorth dhowo...@mrc-lmb.cam.ac.ukwrote: You're right. I want to read data from a MySQL database where some tables use Windows-1252 encoding (i.e what MySQL refers to as latin1) and others use UTF8. It's not latin1. There's a few

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Dave Howorth
Lianna Eeftinck wrote: Afaik, 'mysql_enable_utf8 = 1' (and there are similar options for Postgress and SQLite at least) just tells the mysql driver that if a column is marked as having a UTF8 charset in the table, it'll try to return the data as such. If your column has a different character

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Dave Howorth
Dave Howorth wrote: Apparently I still don't understand enough to use this effectively. If I do my $schemaw = TDB::Schema-connect($dsn, $user, $password); $dbi_params = { mysql_enable_utf8 = 1, on_connect_do = SET NAMES 'utf8', }; my $schemau =

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Lianna Eeftinck
On 16/01/2014 16:44, Dave Howorth wrote: DBIx::Class::ResultSet::find(): DBI Exception: DBD::mysql::st execute failed: COLLATION 'latin1_general_ci' is not valid for CHARACTER SET 'utf8' If you know how to avoid that, I'd be very happy to learn. Sounds like a MySQL (library?) error rather than