How to direct connect to SQLite Database while we're on Expo without export database?


#1

Hello everyone, I have trouble in querying data from database for testing. Could everyone suggest any method to connect it while we’re in development version (expo client) without export database file?
Thanks so much for helping.


#2

So to be clear, you have data in a SQLite database that lives on the phone and you want to connect to it for testing purposes with some tool that lives on your computer?


#3

Yes please… Do you have any suggestion or this is possible method to do that?


#4

hmmm… there are a bunch of ways you could do this, but here is one idea that would probably work:

have your app poll an endpoint every few seconds. if the endpoint has a query at it, have the app run that query, and then serialize the results and POST them to a result endpoint. you could also do something with push notifications if you didn’t want to poll but that seems trickier to get right to me, and if you’re just doing this for testing during development, polling should be fine.


#5

oh… That’s another idea would help me in the future, but i want to connect sqlite database in my device with any sqlite database IDE. I hope you understand… i’m sorry if you don’t.


#6

I’m not sure this is easily possible. SQLite writes to a local file. You could export the SQLite information from your phone to your computer and vice versa, but if you would like to have two computers (ex: your phone and laptop) connect to the same database, it probably makes sense to run your own server that provides HTTP APIs to access your data:

          +-------------------------------+
          |           server              |
+-----+   | +-----------+  +------------+ |
|phone+---+ |server code+--+SQL database| |
+-----+   | +-----------+  +------+-----+ |
          |                       |       |
          +-------------------------------+
                                  |
                             +----+----+
                             |computer |
                             |(SQL IDE)|
                             +---------+

#7

Thanks for your idea. I will try to connect.


#8

I’m about 80% certain this isn’t possible. SQLite is different from other RDBMS’s. It works on shared memory/storage. There is no “SQLite server” in the same sense as there is a mysql server that you can connect to by issuing a cli command. Whereas in mysql you can say mysql -u username -h hostname -p, and on postgres you can do something analogous, and in SQL Server you can connect to “.” with a username and password, in SQLite this concept doesn’t exist.

Since it is file based, ide’s suggestion of downloading the file and figuring out how to browse a SQLite DB may be your best bet.


#9

Thanks for much for your information. I figure out that SQLite is serverless. I agree with your idea.


closed #10

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.