{"action":"created","issue":{"url":"https://api.github.com/repos/psycopg/psycopg2/issues/308","labels_url":"https://api.github.com/repos/psycopg/psycopg2/issues/308/labels{/name}","comments_url":"https://api.github.com/repos/psycopg/psycopg2/issues/308/comments","events_url":"https://api.github.com/repos/psycopg/psycopg2/issues/308/events","html_url":"https://github.com/psycopg/psycopg2/issues/308","id":67302409,"number":308,"title":"Expose libpq PQescapeIdentifier","user":{"login":"dvarrazzo","id":199429,"avatar_url":"https://avatars.githubusercontent.com/u/199429?v=3","gravatar_id":"","url":"https://api.github.com/users/dvarrazzo","html_url":"https://github.com/dvarrazzo","followers_url":"https://api.github.com/users/dvarrazzo/followers","following_url":"https://api.github.com/users/dvarrazzo/following{/other_user}","gists_url":"https://api.github.com/users/dvarrazzo/gists{/gist_id}","starred_url":"https://api.github.com/users/dvarrazzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvarrazzo/subscriptions","organizations_url":"https://api.github.com/users/dvarrazzo/orgs","repos_url":"https://api.github.com/users/dvarrazzo/repos","events_url":"https://api.github.com/users/dvarrazzo/events{/privacy}","received_events_url":"https://api.github.com/users/dvarrazzo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/psycopg/psycopg2/milestones/10","html_url":"https://github.com/psycopg/psycopg2/milestones/psycopg%202.7","labels_url":"https://api.github.com/repos/psycopg/psycopg2/milestones/10/labels","id":1059859,"number":10,"title":"psycopg 2.7","description":null,"creator":{"login":"dvarrazzo","id":199429,"avatar_url":"https://avatars.githubusercontent.com/u/199429?v=3","gravatar_id":"","url":"https://api.github.com/users/dvarrazzo","html_url":"https://github.com/dvarrazzo","followers_url":"https://api.github.com/users/dvarrazzo/followers","following_url":"https://api.github.com/users/dvarrazzo/following{/other_user}","gists_url":"https://api.github.com/users/dvarrazzo/gists{/gist_id}","starred_url":"https://api.github.com/users/dvarrazzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvarrazzo/subscriptions","organizations_url":"https://api.github.com/users/dvarrazzo/orgs","repos_url":"https://api.github.com/users/dvarrazzo/repos","events_url":"https://api.github.com/users/dvarrazzo/events{/privacy}","received_events_url":"https://api.github.com/users/dvarrazzo/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":3,"state":"open","created_at":"2015-04-09T07:44:10Z","updated_at":"2015-10-01T12:33:04Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2015-04-09T07:51:32Z","updated_at":"2015-10-14T10:49:41Z","closed_at":null,"body":"Allow dynamic query creation by string interpolation without resorting to adaptation (as discussed in #209), which would break switching to PQexecParams."},"comment":{"url":"https://api.github.com/repos/psycopg/psycopg2/issues/comments/148012673","html_url":"https://github.com/psycopg/psycopg2/issues/308#issuecomment-148012673","issue_url":"https://api.github.com/repos/psycopg/psycopg2/issues/308","id":148012673,"user":{"login":"dvarrazzo","id":199429,"avatar_url":"https://avatars.githubusercontent.com/u/199429?v=3","gravatar_id":"","url":"https://api.github.com/users/dvarrazzo","html_url":"https://github.com/dvarrazzo","followers_url":"https://api.github.com/users/dvarrazzo/followers","following_url":"https://api.github.com/users/dvarrazzo/following{/other_user}","gists_url":"https://api.github.com/users/dvarrazzo/gists{/gist_id}","starred_url":"https://api.github.com/users/dvarrazzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvarrazzo/subscriptions","organizations_url":"https://api.github.com/users/dvarrazzo/orgs","repos_url":"https://api.github.com/users/dvarrazzo/repos","events_url":"https://api.github.com/users/dvarrazzo/events{/privacy}","received_events_url":"https://api.github.com/users/dvarrazzo/received_events","type":"User","site_admin":false},"created_at":"2015-10-14T10:49:41Z","updated_at":"2015-10-14T10:49:41Z","body":"@fogzot I wouldn't put every new feature on the cursor, but I think this specific one is better on the cursor than on the connection or as a global function (which would need a connection or cursor anyway), because I assume you want to compose the query close to where you are going to use it and you already have a cursor. Composing a SQL string is not even really the connection task, which is to manage the db connection and the transaction. We just happen to need one to invoke these functions.\r\n\r\n@a1exsh no, the above is just pseudocode to say \"use the libpq function here\". the hack could be used to put together a Python demo, but I don't really think we need it. I'd write the entire feature in C.\r\n\r\nIf I wanted a quick and dirty `quote_ident` in Python I wouldn't make it a connection method anyway, I would have it exposed in `extensions` taking a connection or cursor as argument, to avoid bloating the connection interface (when you will want to escape literals, bytea, ...) and to allow the function to receive a cursor too.\r\n\r\nSo, to summarize, my favourite interface for these quoting functions are in order:\r\n\r\n1. on the cursor as a `compose()` method, with the functions actually wrapped by objects whose interface is `Composable(\"My string\").adapt(conn_or_curs)` -> `str`\r\n\r\n2. in `_psycopg.so` -> `psycopg2.extensions` as simple functions `str` -> `str`\r\n\r\n3. (actually 3000, but MD doesn't allow me) as connection methods.\r\n"}}