Re: Read MS-SQL data into Postgres via ODBC link? - Mailing list pgsql-general

From Susan Cassidy
Subject Re: Read MS-SQL data into Postgres via ODBC link?
Date
Msg-id 3A51F387FE0CC74D80FA60C146987F2501C3D4E00C26@oc-exchange1.stbernard.com
Whole thread Raw
In response to Re: Read MS-SQL data into Postgres via ODBC link?  ("Jonathan Brinkman" <JB@BlackSkyTech.com>)
Responses Re: Read MS-SQL data into Postgres via ODBC link?  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
List pgsql-general

>From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Jonathan Brinkman
>Sent: Tuesday, July 05, 2011 7:48 AM
>To: pgsql-general@postgresql.org
>Cc: 'Brent Wood'
>Subject: Re: [GENERAL] Read MS-SQL data into Postgres via ODBC link?

>Thanks

>I’m importing into Postgresql 8.4.8 from MSSQL 2005.

> 

>I do not have control over the MSSQL server, it is at a customer’s site. I only have access to read-only views on their server, from which I replicate the data to my postgres staging tables.

> 

>I cannot have the MSSQL server do anything like create .csv files, since it’s not my server and the customer will not do that kind of thing (or create DTS scripts, etc. from the PUSH side).

> 

>I’m hoping there is a way I can simply SELECT from an ODBC source and use that SELECT as part of a Postgres INSERT statement.

 

>I don’t use MySQL for anything.

 

>Thanks much for your response!

> 

>J

 

Just connect to both databases (in Perl or Python, or something), do a select on the MSSQL data on the MSSQL handle.  When you get the row into a set of column variables, just insert the columns via the Postgres handle into the Postgres database.  Simple as pie.  You can prepare the INSERT statement so that multiple executions use bind variables.  Commit every 1000 rows or whatever.

 

Susan

 

pgsql-general by date:

Previous
From: "Jonathan Brinkman"
Date:
Subject: Re: cannot "make USE_PGXS=1" b/c no pgxs.mk exists
Next
From: Alban Hertroys
Date:
Subject: Re: Read MS-SQL data into Postgres via ODBC link?