{"action":"opened","issue":{"url":"https://api.github.com/repos/kennethreitz/records/issues/56","repository_url":"https://api.github.com/repos/kennethreitz/records","labels_url":"https://api.github.com/repos/kennethreitz/records/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/kennethreitz/records/issues/56/comments","events_url":"https://api.github.com/repos/kennethreitz/records/issues/56/events","html_url":"https://github.com/kennethreitz/records/issues/56","id":136973538,"number":56,"title":"Need help with understanding `:key` syntax.","user":{"login":"Phrohdoh","id":4861023,"avatar_url":"https://avatars.githubusercontent.com/u/4861023?v=3","gravatar_id":"","url":"https://api.github.com/users/Phrohdoh","html_url":"https://github.com/Phrohdoh","followers_url":"https://api.github.com/users/Phrohdoh/followers","following_url":"https://api.github.com/users/Phrohdoh/following{/other_user}","gists_url":"https://api.github.com/users/Phrohdoh/gists{/gist_id}","starred_url":"https://api.github.com/users/Phrohdoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Phrohdoh/subscriptions","organizations_url":"https://api.github.com/users/Phrohdoh/orgs","repos_url":"https://api.github.com/users/Phrohdoh/repos","events_url":"https://api.github.com/users/Phrohdoh/events{/privacy}","received_events_url":"https://api.github.com/users/Phrohdoh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-27T21:59:56Z","updated_at":"2016-02-27T21:59:56Z","closed_at":null,"body":"I cannot quite figure out how to insert locals into a query.\r\n\r\n`   ...:     db.query('INSERT INTO persons VALUES(:name, :email)', name=name, email=email)`\r\n\r\n```python\r\nIn [1]: import records as rc, requests as rq, json\r\n\r\nIn [2]: db = rc.Database('sqlite:///users.db')\r\n\r\nIn [3]: r = rq.get('http://api.randomuser.me/?nat=us&results=10')\r\n\r\nIn [4]: j = r.json()['results']\r\n\r\nIn [5]: for rec in j:\r\n   ...:     user = rec['user']\r\n   ...:     name = user['name']\r\n   ...:     email = user['email']\r\n   ...:     db.query('CREATE TABLE IF NOT EXISTS persons (name text, email text)')\r\n   ...:     db.query('INSERT INTO persons VALUES(:name, :email)', name=name, email=email)\r\n   ...:\r\n---------------------------------------------------------------------------\r\nInterfaceError                            Traceback (most recent call last)\r\n/Users/thill/projects/play/python/charity/venv_charity/lib/python3.5/site-packages/sqlalchemy/engine/base.py in _execute_context(self, dialect, constructor, statement, parameters, *args)\r\n   1138                         parameters,\r\n-> 1139                         context)\r\n   1140         except Exception as e:\r\n\r\n/Users/thill/projects/play/python/charity/venv_charity/lib/python3.5/site-packages/sqlalchemy/engine/default.py in do_execute(self, cursor, statement, parameters, context)\r\n    449     def do_execute(self, cursor, statement, parameters, context=None):\r\n--> 450         cursor.execute(statement, parameters)\r\n    451\r\n\r\nInterfaceError: Error binding parameter 0 - probably unsupported type.\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nInterfaceError                            Traceback (most recent call last)\r\n<ipython-input-6-7e8a8900c51d> in <module>()\r\n      4     email = user['email']\r\n      5     db.query('CREATE TABLE IF NOT EXISTS persons (name text, email text)')\r\n----> 6     db.query('INSERT INTO persons VALUES(:name, :email)', name=name, email=email)\r\n```"}}