Created
April 4, 2015 08:00
-
-
Save reactnative/3ba45d552fc9c8176db6 to your computer and use it in GitHub Desktop.
react-native-sqlite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sqlite = require('./react-native-sqlite'); | |
sqlite.open("filename.sqlite", function (error, database) { | |
if (error) { | |
console.log("Failed to open database:", error); | |
return; | |
} | |
var sql = "SELECT a, b FROM table WHERE field=? AND otherfield=?"; | |
var params = ["somestring", 99]; | |
database.executeSQL(sql, params, rowCallback, completeCallback); | |
function rowCallback(rowData) { | |
console.log("Got row data:", rowData); | |
} | |
function completeCallback(error) { | |
if (error) { | |
console.log("Failed to execute query:", error); | |
return | |
} | |
console.log("Query complete!"); | |
database.close(function (error) { | |
if (error) { | |
console.log("Failed to close database:", error); | |
return | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment