{"action":"created","issue":{"url":"https://api.github.com/repos/jiangwen365/pypyodbc/issues/78","repository_url":"https://api.github.com/repos/jiangwen365/pypyodbc","labels_url":"https://api.github.com/repos/jiangwen365/pypyodbc/issues/78/labels{/name}","comments_url":"https://api.github.com/repos/jiangwen365/pypyodbc/issues/78/comments","events_url":"https://api.github.com/repos/jiangwen365/pypyodbc/issues/78/events","html_url":"https://github.com/jiangwen365/pypyodbc/issues/78","id":322664870,"number":78,"title":"Selecting a uniqueidentifier field returns a string that looks like bytes","user":{"login":"junctionapps","id":8778630,"avatar_url":"https://avatars3.githubusercontent.com/u/8778630?v=4","gravatar_id":"","url":"https://api.github.com/users/junctionapps","html_url":"https://github.com/junctionapps","followers_url":"https://api.github.com/users/junctionapps/followers","following_url":"https://api.github.com/users/junctionapps/following{/other_user}","gists_url":"https://api.github.com/users/junctionapps/gists{/gist_id}","starred_url":"https://api.github.com/users/junctionapps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/junctionapps/subscriptions","organizations_url":"https://api.github.com/users/junctionapps/orgs","repos_url":"https://api.github.com/users/junctionapps/repos","events_url":"https://api.github.com/users/junctionapps/events{/privacy}","received_events_url":"https://api.github.com/users/junctionapps/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-14T03:56:58Z","updated_at":"2018-05-16T16:08:02Z","closed_at":null,"author_association":"NONE","body":"I'm not sure if I'm doing something wrong, however, if I select a uuid field from ms sql the console appears to display it as a bytes object by prefixing with b, however, it is actually a str quoted with b''. To get the uuid you need to slice with row['itemid'][2:-1]\r\n\r\nIs that the desired behaviour? Caused some grief when trying to insert the value into another table.\r\n\r\n```\r\n    cursor.execute(\"select voucher_draft.ItemID, voucher_draft.comments \"\r\n                   \"from voucher_draft \"\r\n                   \"where voucher_draft.ExpenseRef = ?\", ('1234123412345', ))\r\n    row = cursor.fetchone()\r\n    print(row['itemid'])\r\n    # yields: b'B335FDAD-DE0B-41DA-BB07-0DA10C04D59A'\r\n    print(type(row['itemid']))\r\n    # yields: <class 'str'>\r\n    print(row['itemid'].upper())\r\n    # yields: B'B335FDAD-DE0B-41DA-BB07-0DA10C04D59A'\r\n    # note the uppercase B \r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/jiangwen365/pypyodbc/issues/comments/389575442","html_url":"https://github.com/jiangwen365/pypyodbc/issues/78#issuecomment-389575442","issue_url":"https://api.github.com/repos/jiangwen365/pypyodbc/issues/78","id":389575442,"user":{"login":"junctionapps","id":8778630,"avatar_url":"https://avatars3.githubusercontent.com/u/8778630?v=4","gravatar_id":"","url":"https://api.github.com/users/junctionapps","html_url":"https://github.com/junctionapps","followers_url":"https://api.github.com/users/junctionapps/followers","following_url":"https://api.github.com/users/junctionapps/following{/other_user}","gists_url":"https://api.github.com/users/junctionapps/gists{/gist_id}","starred_url":"https://api.github.com/users/junctionapps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/junctionapps/subscriptions","organizations_url":"https://api.github.com/users/junctionapps/orgs","repos_url":"https://api.github.com/users/junctionapps/repos","events_url":"https://api.github.com/users/junctionapps/events{/privacy}","received_events_url":"https://api.github.com/users/junctionapps/received_events","type":"User","site_admin":false},"created_at":"2018-05-16T16:08:02Z","updated_at":"2018-05-16T16:08:02Z","author_association":"NONE","body":"Okay, with the following where itemid is a ms sql uniqueidentifier\r\nSQL version from select @@VERSION;\r\n\r\n> (Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64)   Apr  2 2010 15:48:46   Copyright (c) Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1) (Hypervisor) ) \r\n\r\n```\r\n    print(row)\r\n    print(row['itemid'])\r\n    print(type(row['itemid']))\r\n```\r\nBaseline testing prior to changes result:\r\n\r\n> (\"b'5000EB67-5E5E-4828-8D2E-50DD2CDAD800'\", 'Test of Python Voucher Import')\r\n> b'5000EB67-5E5E-4828-8D2E-50DD2CDAD800'\r\n> <class 'str'>\r\n\r\nAfter change to \r\n`SQL_GUID            : (str,                 lambda x: x,                SQL_C_CHAR,         create_buffer,      2048  ,         False         ),`\r\n\r\n> (b'5000EB67-5E5E-4828-8D2E-50DD2CDAD800', 'Test of Python Voucher Import')\r\n> b'5000EB67-5E5E-4828-8D2E-50DD2CDAD800'\r\n> <class 'bytes'>\r\n\r\nTo me that seems to solve my issue. Thank you for the help! I suspect you will manage a pull request, however, I can if needed."}}
{"actor":{"display_login":"junctionapps"}}