Skip to content

Instantly share code, notes, and snippets.

@gaving
Created October 29, 2017 17:30
Show Gist options
  • Save gaving/a2b54a96192624e3801dc8db5bd5e00f to your computer and use it in GitHub Desktop.
Save gaving/a2b54a96192624e3801dc8db5bd5e00f to your computer and use it in GitHub Desktop.
expo db test
:29:28 PM: Finished downloading to file:///var/mobile/Containers/Data/Application/2EE289E6-53FC-4D51-8B1D-7B2BCA90325D/Documents/ExponentExperienceData/%2540anonymous%252Flexi-8f3cd9c8-b7dc-431f-a1e5-db19836a96aa/SQLite/db.db
5:29:28 PM: Object {
5:29:28 PM: "exists": 1,
5:29:28 PM: "isDirectory": false,
5:29:28 PM: "modificationTime": 1509298164.3419247,
5:29:28 PM: "size": 1067008,
5:29:28 PM: "uri": "file:///var/mobile/Containers/Data/Application/2EE289E6-53FC-4D51-8B1D-7B2BCA90325D/Documents/ExponentExperienceData/%2540anonymous%252Flexi-8f3cd9c8-b7dc-431f-a1e5-db19836a96aa/SQLite/db.db",
5:29:28 PM: }
5:29:28 PM: WebSQLDatabase {
5:29:28 PM: "_currentTask": null,
5:29:28 PM: "_db": SQLiteDatabase {
5:29:28 PM: "_name": "db.db",
5:29:28 PM: },
5:29:28 PM: "_running": false,
5:29:28 PM: "_txnQueue": Queue {
5:29:28 PM: "length": 0,
5:29:28 PM: },
5:29:28 PM: "version": "1.0",
5:29:28 PM: }
5:29:28 PM: execute error
5:29:28 PM: WebSQLTransaction {
5:29:28 PM: "_complete": false,
5:29:28 PM: "_error": null,
5:29:28 PM: "_running": true,
5:29:28 PM: "_runningTimeout": false,
5:29:28 PM: "_sqlQueue": Queue {
5:29:28 PM: "first": undefined,
5:29:28 PM: "last": undefined,
5:29:28 PM: "length": 0,
5:29:28 PM: },
5:29:28 PM: "_websqlDatabase": WebSQLDatabase {
5:29:28 PM: "_currentTask": TransactionTask {
5:29:28 PM: "errorCallback": [Function anonymous],
5:29:28 PM: "readOnly": false,
5:29:28 PM: "successCallback": [Function anonymous],
5:29:28 PM: "txnCallback": [Function anonymous],
5:29:28 PM: },
5:29:28 PM: "_db": SQLiteDatabase {
5:29:28 PM: "_name": "db.db",
5:29:28 PM: },
5:29:28 PM: "_running": true,
5:29:28 PM: "_txnQueue": Queue {
5:29:28 PM: "first": undefined,
5:29:28 PM: "last": undefined,
5:29:28 PM: "length": 0,
5:29:28 PM: },
5:29:28 PM: "version": "1.0",
5:29:28 PM: },
5:29:28 PM: }
5:29:30 PM: Error code 10: disk I/O error
- node_modules/expo/src/SQLite.js:21:45 in massageError
- node_modules/expo/src/SQLite.js:33:41 in dearrayifyRow
- ... 13 more stack frames from framework internals
//creates a dummy SQLite DB to create the SQLite folder
async makeSQLiteDirAsync() {
const dbTest = SQLite.openDatabase("db.db");
try {
await dbTest.transaction(tx => tx.executeSql(""));
} catch (e) {
console.log("error while executing SQL in dummy DB");
console.log(e.message);
}
}
async componentDidMount() {
try {
const dbPath = FileSystem.documentDirectory + "SQLite/db.db";
await this.makeSQLiteDirAsync();
await FileSystem.downloadAsync(
"https://github.com/florentroques/expo-remote-sqlite-download/blob/master/Chinook_Sqlite.sqlite?raw=true",
dbPath
);
const message = await FileSystem.getInfoAsync(dbPath);
console.log("Finished downloading to ", dbPath);
console.log(message);
const db = SQLite.openDatabase("db.db");
console.log(db);
await db.transaction(
tx => {
tx.executeSql(
"select * from Album limit 0,1",
[],
(_, { rows }) => {
console.log(JSON.stringify(rows));
},
(etx, error) => {
console.log("execute error");
console.log(etx);
console.log(error);
}
);
},
error => {
console.log("transaction error");
console.log(error);
}
);
} catch (error) {
console.log("other error");
console.error(error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment