Forum Archive

Help: How to connect to sqlite ?

mazzeppa

Hello there,

I am beginner to Python. I just installed Pythonista on my Ipad. In my desktop, I have no difficulties to connect my python script to a sqlite db, I just need the file path. But on my Ipad, how do I connect if by sqlite db in on Ipad Files folder ? Could anyone show me a generic example in how to connect your script to a file in your Ipad ? Thank you very much !

cvp

@mazzeppa said:

on Ipad Files folder

Do you mean "on my iPad" folder in Apple Files app or in Pythonista files?

mazzeppa

Hi,
I mean in Apple Files app.
Thanks

cvp

@mazzeppa you have to, only once, give access of "on my iPad" to Pythonista, by
- in the left files browser of Pythonista
- tap, under external files, open
- tap folder
- tap on my iPad
- tap Done

So Pythonista would have access to this folder.

You should see a line "File Provider Storage"

But with which path? Next lesson

cvp

@mazzeppa next lesson

Assume that you gave access Pythonista to "File Provider Storage" (which is On my IPad in Files).

The path of a file there is like /private/var/mobile/Containers/Shared/AppGroup/EF3F9065-AD98-4DE3-B5DB-21170E88B77F/File Provider Storage/MyFolder/MyFile.xxx where you see a set of hexadecimal digits which will be different on each of your devices.

To know, once, which is this device-id, run this script

import dialogs
print(dialogs.pick_document(types=['public.item']))

and select a file in the folder you want. The script will print a path.

Don't worry about infos of the path, like /tmp/com.omz-software.Pythonista3-Inbox/.

mazzeppa

@cvp said:

@mazzeppa next lesson

Assume that you gave access Pythonista to "File Provider Storage" (which is On my IPad in Files).

The path of a file there is like /private/var/mobile/Containers/Shared/AppGroup/EF3F9065-AD98-4DE3-B5DB-21170E88B77F/File Provider Storage/MyFolder/MyFile.xxx where you see a set of hexadecimal digits which will be different on each of your devices.

To know, once, which is this device-id, run this script
import dialogs print(dialogs.pick_document(types=['public.item']))

and select a file in the folder you want. The script will print a path.

Don't worry about infos of the path, like /tmp/com.omz-software.Pythonista3-Inbox/.

Thank you very much for your step by step tutorial ! I love Python and having it on my Ipad is really wonderful. I have my own Contacts application store on sqlite database. Now I can use that app anywhere ! Thanks again !

cvp

@mazzeppa welcome here