pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ow Mun Heng <Ow.Mun.Heng@wdc.com>
To: pgsql-odbc@postgresql.org
Subject: pgodbc + Excel + msquery + background refresh
Date: Wed, 10 Oct 2007 16:07:14 +0800
Message-ID: <1192003634.442.17.camel@neuromancer.home.net> (raw)

Just wonder if anyone here uses Excel to connect to PG via ODBC.

I'm using it extensively as my platform to get data from PG/MSSQL
directly into excel. (Excel uses the msqry32.exe file which is like a
stripped down sql query tool and returns data directly into excel)

When using mssql, connecting from excel to mssql, I can get the query to
run in the background. Hence, a long running query will not interfere
with normal running of other excel works. Eg: Create new sheets,
graphing etc.

However, when trying to achieve the same thing using PG, somehow it
either :

1. PG/PG_ODBC doesn't parse/handle the request to do the query in the
background
2. I'm doing something wrong.

I'm partial to #1 as it works find on mssql.

Here's a sample query macro which you can stick into Excel. (alt-F11,
Module, Insert-New-Modules)


The Keyword here is "Refresh BackgroundQuery = True"

Sub macro1()

SQL = "Select * from public.tablename limit 5000"
With
ActiveSheet.QueryTables.Add(Connection:=Array(Array("ODBC;DRIVER={PostgreSQL Unicode};DATABASE=public;SERVER=127.0.0.1;PORT=5432;UID=pguser;PWD=pguser")), Destination:=Range("A1"))
                .CommandText = SQL
                .Name = ""
                .FieldNames = True
                .RowNumbers = False
                .FillAdjacentFormulas = False
                .PreserveFormatting = True
                .RefreshOnFileOpen = False
                .BackgroundQuery = True
                .RefreshStyle = xlInsertDeleteCells
                .SavePassword = False
                .SaveData = True
                .AdjustColumnWidth = True
                .RefreshPeriod = 0
                .PreserveColumnInfo = True
                .Refresh BackgroundQuery:=True 
                End If
            End With
End Sub

I think this is like the last hurdle for me from moving from mssql to
PG.

Thanks and hopefully, there will be someone who uses it this way.



view thread (2+ messages)  latest in thread

Message-ID: <1192003634.442.17.camel@neuromancer.home.net>
Permalink:  ../1192003634.442.17.camel@neuromancer.home.net/
Also on:    postgresql.org/message-id/1192003634.442.17.camel@neuromancer.home.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: Ow.Mun.Heng@wdc.com
  Subject: Re: pgodbc + Excel + msquery + background refresh
  In-Reply-To: <1192003634.442.17.camel@neuromancer.home.net>
  References: <1192003634.442.17.camel@neuromancer.home.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox