Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 110408
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: greg [...] turnstep.com
Requestors: mcarey [...] ucar.edu
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 3.6.0



Subject: Document how to include attributes containing spaces in the DSN
Date: Thu, 17 Dec 2015 11:41:36 -0700
To: bug-DBD-Pg [...] rt.cpan.org
From: Maxwell Carey <mcarey [...] ucar.edu>
A user on Stack Overflow asked how to include attributes containing spaces in the DSN: http://stackoverflow.com/q/34317892/176646 I don't normally use Postgres so I had to dig through the source to find out that you can do this by surrounding the value with single quotes, e.g. my $dsn = q{dbi:Pg:db=foo;host=bar;attr='thing with spaces'}; This should be added to the documentation for connect(). The docs should probably also explain how to include backslashes and single quotes in such attributes: # Single-quoted string my $dsn = q{dbi:Pg:db=foo;host=bar;attr='thing with spaces \' single quotes and \\\backslashes'}; or # Double-quoted string my $dsn = qq{dbi:Pg:db=foo;host=bar;attr='thing with spaces \\\' single quotes and \\\\backslashes'}; (Although looking at the code, embedded single quotes don't appear to be handled properly: https://metacpan.org/source/TURNSTEP/DBD-Pg-3.5.3/dbdimp.c#L122)
Made a quick doc update with d0cd664b4c0a6fc8d9859cd972b1416de4c47e43. Wording changes always welcome. :) +Parameters containing unusual characters such as spaces can be wrapped in single quotes +around the value e.g. "dbi:Pg:dbname='spacey name';host=$host"