microsoft / microsoft/sql-server-samples

Issue with sql connector from python using Hashbytes

オープン
#718 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
PowerShell
スター
11.2k
フォーク
9.1k
平均マージ
2日 7時間
マージ済み PR(30日)
14

説明

I am sending this code via odbc connector to my sql server

Select Column,HASHBYTES('SHA2_256', CONVERT(VARBINARY(8),Column)) as Encoded_Column from table

Result is different if I run using connector vs if I run it on the sql server as a query.

I understand the issues with doing it via python hashlib and all, but why if I am just querying database with a connector and querying it, result is different.

One of our old sql legacy code, converts a numerical column in sql using the HASHBYTES function and sha2_256.

The entire process is moving to python as we are putting in some advanced usage on top of the legacy work. However, when using connector, we are calling the same sql code, the HASHBYTES('sha2_256',column_name) id returning values with lot of garbage.

Running the code in sql result in this

Column      Encoded_Column
101286297   0x7AC82B2779116F40A8CEA0D85BE4AA02AF7F813B5383BAC60D5E71B7BDB9F705

Running same sql query from python result in

Column      Encoded_Column
101286297 
b"z\xc8+'y\x11o@\xa8\xce\xa0\xd8[\xe4\xaa\x02\xaf\x7f\x81;S\x83\xba\xc6\r^q\xb7\xbd\xb9\xf7\x05"

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

payload には、リポジトリのファイルもテストも記載されていません。まず Python ODBC connector を介して HASHBYTES クエリを再現し、その返された値を SQL Server の結果と比較してから、その差異が想定されるバイナリ表現によるものか、コネクタの問題によるものかを判断してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python, sql
領域
databases
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。