I’m building a React Native app using Expo and expo-sqlite to store my data locally in an SQLite database. While development has gone fine, inspecting the tables and data is challenging.
I’ve tried:
• console.log the results of queries, but it becomes unmanageable with more than a few rows/columns.
• Searching for tooling like DBeaver or DB Browser for SQLite, but they don’t easily connect to the ephemeral DB on a device or simulator.
• Attempting to export the .db file to my machine, but I haven’t found a straightforward, consistent approach with Expo.
Has anyone solved this in an Expo environment? Are there recommended methods or libraries that let me browse the expo-sqlite data more seamlessly, or a debugging trick I’m missing?
Thanks in advance.
Okay, so it's not perfect but i figured it out. So...
There's this plugin on vscode, (in fact there's a few of them that do the same thing) this one is called sqllite viewer. It allows you to get nice tables in your vscode window using airtable. neat.
If you (like me) have a problem where you're using sqllite to dynamically create tables on initial app startup, you may not have a .db file, but instead, a .js with a bunch of expo-sqllite code in it.
To work around this i did the following.
Using expo-file-system i console.logged the directory of the database.
if (Platform.OS === 'ios') {
console.log('App Directory:', FileSystem.documentDirectory);
}
This gave me an ugly path that was impossible to find thanks to Mac OS. So instead i just CMD + Clicked on the file path and it opened in the next tab and boom, all my data was nicely formatted