Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: mssqlserver dsn

by Rhose (Priest)
on Mar 24, 2003 at 21:58 UTC ( #245554=note: print w/replies, xml ) Need Help??

in reply to mssqlserver dsn

Not exactly the answer to your question, but here is some concept code I left in my temp directory which might help.
#/usr/bin/perl -w use strict; use DBI; my $DSN = 'dbi:ODBC:driver={SQL Server};server={myserver};database={my +db}'; my $dbh = DBI->connect($DSN, undef, undef) or die "$DBI::errstr\n"; my $gSQLCmd = 'SELECT col1, col2, col3 FROM mytable'; my $gSQLHandle = $dbh->prepare ( $gSQLCmd ) || die 'Error with SQL statement ['.$DBI::errstr.' - '.$DBI::err.' +]'; $gSQLHandle->execute() || die 'Error with SQL statement ['.$DBI::errst +r.' - '.$DBI::err.']'; while (my @gFields = $gSQLHandle->fetchrow_array) { print 'Row: ',$gFields[0],"\t",$gFields[1],"\t",$gFields[2],"\n"; } $dbh->disconnect;

The code will work a little better if you replace myserver, mydb, and mytable with ones from your actual system. *Smiles* Also, please note that this code connects to the database without a userid or password -- it is using my domain account for authorization.

Update I forgot to give credit where credit is due -- my code is based on the information from DBD::ODBC Connecting without DSN from Win32 by sparkyichi

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://245554]
[Corion]: In fact, the whole thing is just four simple programs, one App::scrape, another being DBIx::RunSQL, and one some glue to convert a JSON object into an SQL INSERT statement (+DBI connect/execute), so it would be an incredibly simple solution...
[Corion]: ... but that simplicity falls down due to SQLite letting me down and me being too lazy to move to a real DB. Maybe DBD::CSV can handle window functions...
[hippo]: Pg has the "trust" mechanism if you don't fancy using credentials for a trivial db.
[Corion]: hippo: Oooh, that sounds quite nice - let me read the documentation on that :)
[hippo]: https://www. docs/current/ static/auth- methods.html#AUTH- TRUST
[erix]: or compile & run an instance as yourself (not user 'postgres')
[erix]: easiest setup is to run with PG* env variables set, and a custom .pgpass files (can be a $PGPASSFILE)
[Corion]: Hmm - "trust" sounds interesting, but I have still to find whether I can restrict that on a per-DB level ;)
[Corion]: erix: Sure, but SQLite doesn't even need that :)

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2018-02-23 15:10 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (302 votes). Check out past polls.