Closed AlesKracik closed 7 years ago
Can you link me to MS SQL docs about this host\instance
notation please? As I know nothing about it, at the moment it's not implemented in pgloader you are right.
https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/logging-in-to-sql-server http://stackoverflow.com/questions/3461005/sql-connection-with-public-ip-named-instance-and-port-number http://jtds.sourceforge.net/faq.html https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url
If I read the FreeTDS documentation correctly you need to set an instance
parameter in your .freetds.conf
file: http://www.freetds.org/userguide/freetdsconf.htm
Can you please try that and report back? If that's the way to make it work, we will of course have to enhance the documentation about it.
Hello. I have the same issue.
I used this page as a guide
$ pgloader --version
pgloader version "3.6.1"
compiled with SBCL 1.4.15.debian
sudo docker run --rm -e 'POSTGRES_PASSWORD=mysecretpassword' -e 'POSTGRES_DB=test' --name 'psql1' -p 5432:5432 -d postgres:12.2-alpine
sudo docker run --rm -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Passw)rd' --name 'mssql1' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
sudo docker exec -it mssql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Passw)rd' -Q 'CREATE DATABASE testdb;'
sudo docker exec -it -e 'POSTGRES_PASSWORD=mysecretpassword' psql1 psql -U postgres -c 'CREATE DATABASE testdb;'
[global]
tds version = 7.4
client charset = UTF-8
[local]
host = localhost
port = 5432
database = testdb
load database
from mssql://SA:Passw)rd@local
into postgresql://postgres:mysecretpassword@localhost:5432/testdb
including only table names like 'GlobalAccount'
set work_mem to '16MB', maintenance_work_mem to '512 MB'
before load do $$ drop schema if exists dbo cascade; $$;
pgloader pgloader_istructions
2022-01-17T12:04:23.005000Z LOG pgloader version "3.6.1"
2022-01-17T12:04:23.052000Z LOG Migrating from #<SQLITE-CONNECTION sqlite:///home/nett00n/mssql:/SA:Passw)rd@local {1006974643}>
2022-01-17T12:04:23.052000Z LOG Migrating into #<PGSQL-CONNECTION pgsql://postgres@localhost:5432/testdb {1006975C53}>
KABOOM!
FATAL error: Failed to open sqlite file #P"/home/nett00n/mssql:/SA:Passw)rd@local": Could not open sqlite3 database /home/nett00n/mssql:/SA:Passw)rd@local
Code CANTOPEN: no message.
An unhandled error condition has been signalled:
Failed to open sqlite file #P"/home/nett00n/mssql:/SA:Passw)rd@local": Could not open sqlite3 database /home/nett00n/mssql:/SA:Passw)rd@local
Code CANTOPEN: no message.
What I am doing here?
Failed to open sqlite file #P"/home/nett00n/mssql:/SA:Passw)rd@local": Could not open sqlite3 database /home/nett00n/mssql:/SA:Passw)rd@local
Code CANTOPEN: no message.
@nett00n I think you may be having a different issue than the one listed above, where the user is trying to specify an instance name.
config ~/.freetds.conf
[global] tds version = 7.4 client charset = UTF-8 [local] host = localhost port = 5432 database = testdb
In your FreeTDS.conf, I believe you can specify an mssql instance like this:
[mssql_instance]
host = instancebox.domain.name
port = 1433
database = testdb
instance = foo
Default port for mssql is 1433. microsoft notation of an mssql instance might be something like (as seen above) :
USCTAPD00051\00051PS10
mssqlBoxName\mssqlInstanceName
Forgive me, I'm slightly confused how your mssql box and postgres box could both be localhost. When I've used pgloader, pgloader is installed on the machine that is running postgres, so this connection is local, but the mssql connection I have specified with a fully qualified domain name, or just the mssql server host name such as USCTAPD00051 above.
FreeTDS seems to support this notation now, though I haven't been able to get it to work, and I'm uncertain how to specify the FreeTDS entry in pgloader, when I try :
pgloader version 3.6.3~devel
compiled with SBCL 2.0.1.debian
sb-impl::*default-external-format* :UTF-8
tmpdir: #P"/tmp/pgloader/"
2022-01-20T10:36:28.006000-08:00 NOTICE Starting pgloader, log system is ready.
2022-01-20T10:36:28.023000-08:00 INFO Starting monitor
2022-01-20T10:36:28.027000-08:00 LOG pgloader version "3.6.3~devel"
2022-01-20T10:36:28.078000-08:00 INFO Parsed command:
load database
from mssql://Domain\ARCHIVESERVICE:password@mssql_instance
into postgresql://archiveservice:password@localhost:5432/archive
;
2022-01-20T10:36:28.079000-08:00 LOG DRY RUN, only checking connections.
2022-01-20T10:36:28.080000-08:00 LOG Attempting to open #<SQLITE-CONNECTION sqlite://~/mssql:/DOMAINarchiveservice:password@mssql_instance.load {1008086A53}>
2022-01-20T10:36:28.095000-08:00 FATAL Failed to connect to #<SQLITE-CONNECTION sqlite://~/mssql:/DOMAINarchiveservice:password@mssql_instance.load {1008086A53}>: Failed to open sqlite file #P"~/mssql:/DOMAINarchiveservice:password@mssql_instance.load": Could not open sqlite3 database ~/mssql:/DOMAINarchiveservice:password@mssql_instance.load
Code CANTOPEN: no message.
2022-01-20T10:36:28.095000-08:00 LOG Attempting to connect to #<PGSQL-CONNECTION pgsql://archiveservice@localhost:5432/archive {1008088233}>
2022-01-20T10:36:28.134000-08:00 DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://archiveservice@localhost:5432/archive {1008088233}>
2022-01-20T10:36:28.139000-08:00 LOG Success, opened #<PGSQL-CONNECTION pgsql://archiveservice@localhost:5432/archive {1008088233}>.
2022-01-20T10:36:28.139000-08:00 LOG Running a simple query: SELECT 1;
2022-01-20T10:36:28.145000-08:00 SQL SELECT 1;
2022-01-20T10:36:28.146000-08:00 LOG report summary reset
table name errors read imported bytes total time read write
----------------- --------- --------- --------- --------- -------------- --------- ---------
----------------- --------- --------- --------- --------- -------------- --------- ---------
2022-01-20T10:36:28.231000-08:00 INFO Stopping monitor
pgloader version 3.6.3~devel
compiled with SBCL 2.0.1.debian
sb-impl::*default-external-format* :UTF-8
tmpdir: #P"/tmp/pgloader/"
2022-01-20T10:56:18.007000-08:00 NOTICE Starting pgloader, log system is ready.
2022-01-20T10:56:18.028000-08:00 INFO Starting monitor
2022-01-20T10:56:18.036000-08:00 LOG pgloader version "3.6.3~devel"
2022-01-20T10:56:18.080000-08:00 INFO Parsed command:
load database
from mssql://DOMAIN\archiveservice:password@mssqlBOX2:1433/testDB
into postgresql://archiveservice:password@localhost:5432/archive
;
2022-01-20T10:56:18.082000-08:00 LOG Loading the FreeTDS shared librairy (sybdb)
2022-01-20T10:56:18.085000-08:00 LOG DRY RUN, only checking connections.
2022-01-20T10:56:18.086000-08:00 LOG Attempting to connect to #<MSSQL-CONNECTION mssql://DOMAIN\archiveservice@mssqlBOX2:1433/testDB {10080F16B3}>
Max connections reached, increase value of TDS_MAX_CONN
2022-01-20T10:56:18.156000-08:00 LOG Success, opened #<MSSQL-CONNECTION mssql://DOMAIN\archiveservice@mssqlBOX2:1433/testDB {10080F16B3}>.
2022-01-20T10:56:18.156000-08:00 LOG Running a simple query: SELECT 1;
2022-01-20T10:56:18.162000-08:00 SQL MSSQL: sending query: SELECT 1;
2022-01-20T10:56:18.164000-08:00 LOG Attempting to connect to #<PGSQL-CONNECTION pgsql://archiveservice@localhost:5432/archive {10080F2E83}>
2022-01-20T10:56:18.218000-08:00 DEBUG CONNECTED TO #<PGLOADER.PGSQL:PGSQL-CONNECTION pgsql://archiveservice@localhost:5432/archive {10080F2E83}>
2022-01-20T10:56:18.226000-08:00 LOG Success, opened #<PGSQL-CONNECTION pgsql://archiveservice@localhost:5432/archive {10080F2E83}>.
2022-01-20T10:56:18.226000-08:00 LOG Running a simple query: SELECT 1;
2022-01-20T10:56:18.227000-08:00 SQL SELECT 1;
2022-01-20T10:56:18.228000-08:00 LOG report summary reset
table name errors read imported bytes total time read write
----------------- --------- --------- --------- --------- -------------- --------- ---------
----------------- --------- --------- --------- --------- -------------- --------- ---------
2022-01-20T10:56:18.320000-08:00 INFO Stopping monitor
Hi,
when I'm trying to use pgloader for MSSQL with instance, using config file below
throws me this error, so it seems to me, that it actually does not recognize the usage of host\instnce as valid connection string