Re: How to create an ODBC datasource in CI

From: Adrian Grucza <adrian(dot)grucza(at)iress(dot)com>
To: Dave Cramer <davecramer(at)gmail(dot)com>
Cc: Jon Raiford <raiford(at)labware(dot)com>, PostgreSQL mailing lists <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: How to create an ODBC datasource in CI
Date: 2024-03-30 10:17:04
Message-ID: CADF4wWr2sMJ+RYOwe5PDNHobVm6dDLtKQfXLv59UcGyqr5-YgQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

If your aim is to run the regression tests then winbuild/regress.ps1 does
everything for you: installs a dev version of the driver, creates a DSN for
it and runs the tests against a PostgreSQL server (which you could run in
Docker).

But if you want to use the MSI installer, running that will install the
driver for you:

Start-Process 'C:\\psqlodbc_x64.msi' '/quiet /passive' -PassThru |
Wait-Process;

You then just need to create the DSN:

Add-OdbcDsn -Name "MyPostgresDsn" -DsnType 'User' -Platform '64-bit'
-DriverName 'PostgreSQL Unicode(x64)'

Set-OdbcDsn -Name "MyPostgresDsn" `
-DsnType "User" `
-SetPropertyValue @("Servername=${env:DB_HOST}" `
,'Port=5432' `
,"SSLMode=${env:SSL_MODE}" `
,'BoolsAsChar=0' `
,'FetchRefcursors=1' `
,'MaxVarcharSize=4094' `
)

Adrian Grucza
Technical Lead
Office: +61390185800
The contents of this email originated from Iress. For this purpose Iress includes Iress Limited and/or any of its subsidiaries, holding companies and trading entities.
​​If you have received this email in error please notify the sender immediately and delete this email.
On Sat, 30 Mar 2024 at 6:53 pm, Dave Cramer <davecramer(at)gmail(dot)com> wrote:

>
>
> *CAUTION: *This Email is from an EXTERNAL source. Ensure you trust this
> sender before clicking on any links or attachments.
>
>
>
>
> On Fri, 29 Mar 2024 at 18:49, Adrian Grucza <adrian(dot)grucza(at)iress(dot)com>
> wrote:
>
>> winbuild/regress.ps1 uses RegisterRegdsn.exe (built from
>> test/RegisterRegdsn.c) to install the driver and register a data source.
>> You could use that, or you may find it easier to use the Wdac cmdlets
>> <https://urldefense.com/v3/__https://learn.microsoft.com/en-us/powershell/module/wdac/?view=windowsserver2022-ps__;!!OSkwEA!gCqZhyHagy3EZmgiOmuwocdpV-3R-QcgE_7CIaErQdc74VCne94pcDCufFPcWI0H77tfxQMSrAT1qmFl__3d$> in
>> PowerShell, specifically Add-OdbcDsn and Set-OdbcDsn.
>>
>>
> Yes, I saw those, was going to try them. I think the challenge is
> registering the driver first though.
>
> Dave
>
>>
>> [image: iress.com] <https://www.iress.com/>
>> Adrian Grucza
>> Technical Lead
>> Office: +61390185800
>> adrian(dot)grucza(at)iress(dot)com
>> www.iress.com
>> Level 16 385 Bourke St
>> <https://www.google.com/maps/search/385%C2%A0Bourke%C2%A0St+%C2%A0Melbourne?entry=gmail&source=g>
>> Melbourne
>> <https://www.google.com/maps/search/385%C2%A0Bourke%C2%A0St+%C2%A0Melbourne?entry=gmail&source=g>
>> , Victoria, 3000
>> The contents of this email originated from Iress. For this purpose Iress
>> includes Iress Limited and/or any of its subsidiaries, holding companies
>> and trading entities. If you have received this email in error please
>> notify the sender immediately and delete this email.
>> nosig
>>
> On Sat, 30 Mar 2024 at 2:12 am, Dave Cramer <davecramer(at)gmail(dot)com> wrote:
>>
>>>
>>>
>>> *CAUTION: *This Email is from an EXTERNAL source. Ensure you trust this
>>> sender before clicking on any links or attachments.
>>>
>>>
>>>
>>>
>>> On Fri, 29 Mar 2024 at 08:41, Jon Raiford <raiford(at)labware(dot)com> wrote:
>>>
>>>> I’m not familiar with GitHub Actions, but I know you can create data
>>>> sources from the command line. This is all stored in the registry, which
>>>> you can update using the reg command.
>>>>
>>>>
>>>>
>>>>
>>>> https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg
>>>> <https://urldefense.com/v3/__https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/reg__;!!OSkwEA!kxnwxUJLKxa3Oc4LrkTTgAXa9D0wwxO8NOTXoz4JjxveQ82EajBPe0J1twXNrVystZJlxhAOFAQi5AyABfRE$>
>>>>
>>>>
>>>>
>>>> The easiest thing to do may be to create a data source manually and
>>>> export it into a .reg file. You can then either import the data source
>>>> using the reg file or just use it as a template to add the entries as you
>>>> like.
>>>>
>>>>
>>>> Just run Regedit and locate the data source you would like to export.
>>>>
>>>>
>>>>
>>>> 64-bit System Data Sources: \\HKLM\SOFTWARE\ODBC\
>>>> <https://urldefense.com/v3/__http://HKLM/SOFTWARE/ODBC/__;!!OSkwEA!kxnwxUJLKxa3Oc4LrkTTgAXa9D0wwxO8NOTXoz4JjxveQ82EajBPe0J1twXNrVystZJlxhAOFAQi5K4hxQRA$>
>>>>
>>>> 32-bit System Data Sources: \\HKLM\SOFTWARE\WOW6432Node\ODBC\
>>>> <https://urldefense.com/v3/__http://HKLM/SOFTWARE/WOW6432Node/ODBC/__;!!OSkwEA!kxnwxUJLKxa3Oc4LrkTTgAXa9D0wwxO8NOTXoz4JjxveQ82EajBPe0J1twXNrVystZJlxhAOFAQi5EngC-Q_$>
>>>>
>>>> 64-bit User Data Sources: \\HKCU\SOFTWARE\ODBC\
>>>>
>>>> 32-bit User Data Sources: \\HKCU\SOFTWARE\ODBC\
>>>> <https://urldefense.com/v3/__http://HKCU/SOFTWARE/ODBC/__;!!OSkwEA!kxnwxUJLKxa3Oc4LrkTTgAXa9D0wwxO8NOTXoz4JjxveQ82EajBPe0J1twXNrVystZJlxhAOFAQi5CXxcTt4$>
>>>> <- This is mixed in with the 64-bit entries and the driver referenced
>>>> determines if 32/64
>>>>
>>>>
>>>>
>>>> Drivers are defined under the system keys under the section
>>>> ODBCINST.INI. Data sources are defined under the section ODBC.INI, both as
>>>> a folder containing the details of the data source as well as an entry
>>>> under “ODBC.INI\ODBC Data Sources”, which associates the data source with
>>>> the driver to use with it.
>>>>
>>>>
>>>>
>>>> I think if you view these entries in Regedit you will see the
>>>> relationships between everything. It may help to create a data source for
>>>> each type.
>>>>
>>>>
>>>>
>>>> The above describes how to create a static ODBC data source.
>>>> Alternatively you can use a file DSN or simply make a connection string
>>>> from your test case and avoid the data source completely. Although I
>>>> suppose you may want to do each in order to test each possibility.
>>>>
>>>>
>>>>
>>>> Let me know if you have any questions or need assistance.
>>>>
>>>>
>>>>
>>>> Jon
>>>>
>>>
>>> Hey Jon,
>>>
>>> Thanks, that will help immensely.
>>>
>>> It's been a while since I've done anything with Windows.
>>>
>>> Dave
>>>
>>>>
>>>>
>>>>
>>>>
>>>> *From: *Dave Cramer <davecramer(at)gmail(dot)com>
>>>> *Date: *Friday, March 29, 2024 at 7:25 AM
>>>> *To: *PostgreSQL mailing lists <pgsql-odbc(at)postgresql(dot)org>
>>>> *Subject: *How to create an ODBC datasource in CI
>>>>
>>>> Greetings,
>>>>
>>>>
>>>>
>>>> In order to test the driver using github actions we need to be able to
>>>> create a windows datasource. Usually this requires some kind of user
>>>> interaction.
>>>>
>>>>
>>>>
>>>> Has anyone done this on GH actions ?
>>>>
>>>>
>>>>
>>>>
>>>> Dave Cramer
>>>>
>>>

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Dave Cramer 2024-03-30 11:08:40 Re: How to create an ODBC datasource in CI
Previous Message Dave Cramer 2024-03-30 07:52:54 Re: How to create an ODBC datasource in CI