{"action":"created","issue":{"url":"https://api.github.com/repos/ccgus/fmdb/issues/362","labels_url":"https://api.github.com/repos/ccgus/fmdb/issues/362/labels{/name}","comments_url":"https://api.github.com/repos/ccgus/fmdb/issues/362/comments","events_url":"https://api.github.com/repos/ccgus/fmdb/issues/362/events","html_url":"https://github.com/ccgus/fmdb/issues/362","id":67639486,"number":362,"title":"Can't Insert Dictionary (JSON) into DB","user":{"login":"mikewalkerjr","id":4707821,"avatar_url":"https://avatars.githubusercontent.com/u/4707821?v=3","gravatar_id":"","url":"https://api.github.com/users/mikewalkerjr","html_url":"https://github.com/mikewalkerjr","followers_url":"https://api.github.com/users/mikewalkerjr/followers","following_url":"https://api.github.com/users/mikewalkerjr/following{/other_user}","gists_url":"https://api.github.com/users/mikewalkerjr/gists{/gist_id}","starred_url":"https://api.github.com/users/mikewalkerjr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikewalkerjr/subscriptions","organizations_url":"https://api.github.com/users/mikewalkerjr/orgs","repos_url":"https://api.github.com/users/mikewalkerjr/repos","events_url":"https://api.github.com/users/mikewalkerjr/events{/privacy}","received_events_url":"https://api.github.com/users/mikewalkerjr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-10T17:05:16Z","updated_at":"2015-04-10T18:23:38Z","closed_at":null,"body":"I'm attempting to insert a JSON object into my DB. I'm using swift 1.2. I have read that for NSDictionary, the parameter must be prefixed with a colon. Here is the code that I have after opening the DB:\r\n\r\n    let insertSQL = \"INSERT OR REPLACE INTO filters (memberId,name,data) VALUES (\\(memberId), \\(filterId), :\\(json))\"         \r\n    let result = db.executeUpdate(insertSQL, withArgumentsInArray: nil)\r\n\r\nWhen I run the code, I get the following error:\r\n\r\n    \"DB Error: 1 \"unrecognized token \":\"\"\r\n\r\nAm I not putting the prefixed colon in the correct spot?"},"comment":{"url":"https://api.github.com/repos/ccgus/fmdb/issues/comments/91644584","html_url":"https://github.com/ccgus/fmdb/issues/362#issuecomment-91644584","issue_url":"https://api.github.com/repos/ccgus/fmdb/issues/362","id":91644584,"user":{"login":"robertmryan","id":1530768,"avatar_url":"https://avatars.githubusercontent.com/u/1530768?v=3","gravatar_id":"","url":"https://api.github.com/users/robertmryan","html_url":"https://github.com/robertmryan","followers_url":"https://api.github.com/users/robertmryan/followers","following_url":"https://api.github.com/users/robertmryan/following{/other_user}","gists_url":"https://api.github.com/users/robertmryan/gists{/gist_id}","starred_url":"https://api.github.com/users/robertmryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertmryan/subscriptions","organizations_url":"https://api.github.com/users/robertmryan/orgs","repos_url":"https://api.github.com/users/robertmryan/repos","events_url":"https://api.github.com/users/robertmryan/events{/privacy}","received_events_url":"https://api.github.com/users/robertmryan/received_events","type":"User","site_admin":false},"created_at":"2015-04-10T18:23:38Z","updated_at":"2015-04-10T18:23:38Z","body":"It's not entirely clear to me what you were trying to do, i.e., why that colon is there. But, I notice that you're doing string interpolation, which I would not advise. I'd suggest using placeholders. You can either use `?` placeholders with an array of arguments:\r\n\r\n    let insertSQL = \"INSERT OR REPLACE INTO filters (memberId, name, data) VALUES (?, ?, ?)\"\r\n    let result = db.executeUpdate(insertSQL, withArgumentsInArray: [memberId, filterId, json])\r\n\r\nOr you can use named parameters with a dictionary of values:\r\n\r\n    let insertSQL = \"INSERT OR REPLACE INTO filters (memberId, name, data) VALUES (:memberId, :filterId, :json)\"\r\n    let result = db.executeUpdate(insertSQL, withParameterDictionary: [\"memberId\" : memberId, \"filterId\" : filterId, \"json\" : json])\r\n\r\nIn terms of storing a dictionary in the database as JSON string, while I might not be inclined to do it that way, neither FMDB nor SQLite care what values you insert. But it should either be the `String` or `NSData` representation of the JSON, but not an array/dictionary."}}