opendatadiscovery / odd-collectors

Apache License 2.0
8 stars 9 forks source link

Can't connect to SQL Server using mssql adapter or odbc adapters #95

Open CathyBreslow opened 1 month ago

CathyBreslow commented 1 month ago

Hello! I successfully connected ODD to our production Postgres data warehouse, and I need to connect to our SQL server databases for lineage. I'm having issues connecting to one of our SQL servers using both adapters.

I'm getting errors trying to create a MSSQL collector using either the MSSQL adapter or the ODBC adapter. I can connect to this database using DBeaver software using the exact same credentials so I know it's not necessarily a network problem.

Here's the error using the MSSQL Adapter: 2024-07-18 14:49:38.474 | ERROR | odd_collector_sdk.collector:run:137 - Could not create data sources. Reason: 500, message='Internal Server Error', url=URL('http://odd-platform:8080/ingestion/datasources') This is the exact text in my collector_config.yaml for this collector: (sensitive data replaced)

default_pulling_interval: 60 token: "xxxx" plugins:

And here's the ODBC adapter info: default_pulling_interval: 10 token: "xxxx" plugins:

I am more than happy to try any tests for fixes you can give me!

Thank you, Cathy Breslow

ValeriyWorld commented 1 month ago

@CathyBreslow Hello! I have run mssql and odbc adapters on some test database with a few tables + views. Seems like both of adapters are working. 1) mssql: Successful collector logs:

image

ODD Platform result:

350738565-fef61ee2-b887-43f9-b07f-de12d8812c3f

At first I would suggest you to check if the version of collector is up to date. It can be easily checked when you run a collector, it is the first row of the logs. The most up to date version is 0.1.63, which can be pulled with ghcr.io/opendatadiscovery/odd-collector:latest (make sure that Docker didn't cache the old image, in this case delete the old one and pull once more). The next thing you may have issue with is the following: there is already a datasource created with the name you specified. For example you have already some datasource , for different adapter, now you changed the adapter configuration (plugin section in collector_config.yaml) but the name remained the same name: "<datasource_name>", in this way platform is trying to create a new adapter for new configuration, but can not, because the one with this name already exists. So try to change name attribute of the plugin.

2) odbc: This adapters worked fine as well in my quick test, but it collects a lot of system views that can not be needed, so can make a mess in the platform. If it will be a problem we can discuss this later. Also successful collector logs:

image

ODD Platform result:

350740612-2c577be7-21c1-4185-9996-de0ae4be26d1

I did some investigation and found out, that there are no proper error handling in odbc adapter, so if you did some mistake in the configuration, for example in the host - it can lead to this not good explaining "Could not map table" error for now. Information about drivers you may find in the ODBC Data Source Administrator -> Drivers.

image

So you need the exactly the name for driver, and may put it in the {}, or left w/o them, both seems to work fine. As I can see the problem could be in the driver name, you version - "ODBC Driver 17s for SQL Server", seems like s in 17s is redundant. My odbc plugin configuration looked like this than I ran a collector:

  - type: "odbc"
    name: "odbc_adapter"
    description: "" # Optional string
    database: "<db_name>"
    user: "<user_name>"
    password: "<db_password>"
    host: "<host>"
    port: "1433"
    driver: "{ODBC Driver 17 for SQL Server}"

I guess you should get the result after driver name fix. But also I may assume that the same "Could not map table" error can appear in case of lack of user's permissions, because adapter is getting metadata from system tables and views too.

For quick summarisation: you better try mssql adapter once more, as I write, try to change the name property in collector_config.yaml - it is used for datasource name generation and must be unique for different configurations. And for odbc - try to fix driver name.

CathyBreslow commented 1 month ago

Thank you!

Does the version of MSSql matter? I’m trying to connect to a database that’s on 2008.

Cathy Breslow | Data Engineer Phone: 510-264-3834 Email: @.**@.> | www.gillig.comhttp://www.gillig.com HQ: 510.264.5000 | Sales 510.785.1500 | Parts 800.735.1500 | Service 510.264.5073

CONFIDENTIALITY WARNING: This email may contain proprietary or confidential information and is for the sole use of the intended recipient(s). Any unauthorized use or disclosure of this communication is prohibited. If you believe that you have received this email in error, please notify the sender immediately and delete it from your system.

From: Valerii Mironchenko @.> Reply-To: opendatadiscovery/odd-collectors @.> Date: Saturday, July 20, 2024 at 11:41 PM To: opendatadiscovery/odd-collectors @.> Cc: Cathy Breslow @.>, Mention @.***> Subject: Re: [opendatadiscovery/odd-collectors] Can't connect to SQL Server using mssql adapter or odbc adapters (Issue #95)

@CathyBreslowhttps://urldefense.com/v3/__https:/github.com/CathyBreslow__;!!NLX6_q7s!zPBGYwd_oztawRMeT7UwybMGZYaEmESxC539lu_KxtIQsHRMeLxoWaJCp6-Fh2VbqwKAm0PzHwOB04dy_u0XtwqXuKev$ Hello! I have run mssql and odbc adapters on some test database with a few tables + views. Seems like both of adapters are working.

  1. mssql: Successful collector logs: image.png (view on web)https://urldefense.com/v3/__https:/github.com/user-attachments/assets/227f6589-9ed2-4c68-bc91-1570b304d4b3__;!!NLX6_q7s!zPBGYwd_oztawRMeT7UwybMGZYaEmESxC539lu_KxtIQsHRMeLxoWaJCp6-Fh2VbqwKAm0PzHwOB04dy_u0Xt8q2HxvR$ ODD Platform result: 350738565-fef61ee2-b887-43f9-b07f-de12d8812c3f.png (view on web)https://urldefense.com/v3/__https:/github.com/user-attachments/assets/718542e0-31f3-4d33-87b0-d618bdc65cd7__;!!NLX6_q7s!zPBGYwd_oztawRMeT7UwybMGZYaEmESxC539lu_KxtIQsHRMeLxoWaJCp6-Fh2VbqwKAm0PzHwOB04dy_u0Xt1WSqJIg$

At first I would suggest you to check if the version of collector is up to date. It can be easily checked when you run a collector, it is the first row of the logs. The most up to date version is 0.1.63, which can be pulled with ghcr.io/opendatadiscovery/odd-collector:latest (make sure that Docker didn't cache the old image, in this case delete the old one and pull once more). The next thing you may have issue with is the following: there is already a datasource created with the name you specified. For example you have already some datasource , for different adapter, now you changed the adapter configuration (plugin section in collector_config.yaml) but the name remained the same name: "", in this way platform is trying to create a new adapter for new configuration, but can not, because the one with this name already exists. So try to change name attribute of the plugin.

  1. odbc: This adapters worked fine as well in my quick test, but it collects a lot of system views that can not be needed, so can make a mess in the platform. If it will be a problem we can discuss this later. Also successful collector logs: image.png (view on web)https://urldefense.com/v3/__https:/github.com/user-attachments/assets/3024c15f-88db-456c-8d99-5b44ec2c342c__;!!NLX6_q7s!zPBGYwd_oztawRMeT7UwybMGZYaEmESxC539lu_KxtIQsHRMeLxoWaJCp6-Fh2VbqwKAm0PzHwOB04dy_u0Xt3LHWqyo$ ODD Platform result: 350740612-2c577be7-21c1-4185-9996-de0ae4be26d1.png (view on web)https://urldefense.com/v3/__https:/github.com/user-attachments/assets/dde4fd24-4704-4a6a-a01a-432631824180__;!!NLX6_q7s!zPBGYwd_oztawRMeT7UwybMGZYaEmESxC539lu_KxtIQsHRMeLxoWaJCp6-Fh2VbqwKAm0PzHwOB04dy_u0Xty8J2VqR$

I did some investigation and found out, that there are no proper error handling in odbc adapter, so if you did some mistake in the configuration, for example in the host - it can lead to this not good explaining "Could not map table" error for now. Information about drivers you may find in the ODBC Data Source Administrator -> Drivers. image.png (view on web)https://urldefense.com/v3/__https:/github.com/user-attachments/assets/9269a871-eb55-4500-942c-c86151fe8ddc__;!!NLX6_q7s!zPBGYwd_oztawRMeT7UwybMGZYaEmESxC539lu_KxtIQsHRMeLxoWaJCp6-Fh2VbqwKAm0PzHwOB04dy_u0Xt6W3KK3M$ So you need the exactly the name for driver, and may put it in the {}, or left w/o them, both seems to work fine. As I can see the problem could be in the driver name, you version - "ODBC Driver 17s for SQL Server", seems like s in 17s is redundant. My odbc plugin configuration looked like this than I ran a collector:

I guess you should get the result after driver name fix. But also I may assume that the same "Could not map table" error can appear in case of lack of user's permissions, because adapter is getting metadata from system tables and views too.

For quick summarisation: you better try mssql adapter once more, as I write, try to change the name property in collector_config.yaml - it is used for datasource name generation and must be unique for different configurations. And for odbc - try to fix driver name.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/opendatadiscovery/odd-collectors/issues/95*issuecomment-2241497966__;Iw!!NLX6_q7s!zPBGYwd_oztawRMeT7UwybMGZYaEmESxC539lu_KxtIQsHRMeLxoWaJCp6-Fh2VbqwKAm0PzHwOB04dy_u0Xt2Wxg7tw$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/APVNOI3ZYSWVIKHHROYLRSLZNNJYHAVCNFSM6AAAAABLC6GIGWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBRGQ4TOOJWGY__;!!NLX6_q7s!zPBGYwd_oztawRMeT7UwybMGZYaEmESxC539lu_KxtIQsHRMeLxoWaJCp6-Fh2VbqwKAm0PzHwOB04dy_u0Xt7JRv5rP$. You are receiving this because you were mentioned.Message ID: @.***>

Cathy Breslow | Data Engineer

510-264-3834 | @.**@.> | gillig.comhttps://www.gillig.com/

HQ 510.264.5000 | Sales 510.785.1500 | Parts 510.264.5160 | Service 510.264.5073 [https://static.wixstatic.com/media/df7719_f52c926a931540d49392b90e57967ea5~mv2.png/v1/fill/w_285,h_79/GILLIG_Logo_Blue%20300_no%20Margin.png] http://www.gillig.com [https://static.wixstatic.com/media/df7719_1d7fa680e26346bebc4bb99c29ddf9a0~mv2.png/v1/fill/w_100,h_100/social_media-03.png]https://twitter.com/gilligllc [https://static.wixstatic.com/media/df7719_4e52f88c9bc94d80bf44ef6b30c0311a~mv2.png/v1/fill/w_100,h_100/social_media-02.png] https://www.facebook.com/gilligllc [https://static.wixstatic.com/media/df7719_a934a9dfbec34a3197eb3674a28c874a~mv2.png/v1/fill/w_100,h_100/social_media-04.png] https://www.linkedin.com/company/gillig-llc [https://static.wixstatic.com/media/df7719_0ab1a3df883c48ceaca7d9ef5ec70ec1~mv2.png/v1/fill/w_100,h_100/social_media-01.png] https://www.instagram.com/gilligllc [https://static.wixstatic.com/media/df7719_fe35147cb4af458d8ca740ea2e71da57~mv2.png/v1/fill/w_600,h_6/Line%20break.png] CONFIDENTIALITY WARNING: This email may contain proprietary or confidential information and is for the sole use of the intended recipient(s). Any unauthorized use or disclosure of this communication is prohibited. If you believe that you have received this email in error, please notify the sender immediately and delete it from your system.

ValeriyWorld commented 1 month ago

@CathyBreslow I am not fully sure on this one. It needs to be manually checked. My previous try was on SQL Server 2022.