Is it possible to use Sqlite3 on Android using the Qpython3 app?

Asked

Viewed 141 times

0

I’m trying to create a table:

import sqlite3

def criar_tab_contato(conexao):

   cursor = conexao.cursor()

   sql = """
   CREATE TABLE IF NOT EXISTS contato(
   nome text,
   telefone text,
   senha text
   );
   """

   cursor.execute(sql)


conexao = sqlite3.connect("banco.contato")

criar_tab_contato(conexao)

conexao.close()

But it presents the following error:

 /data/user/0/org.qpython.qpy3/files/bin/qpython-android5.sh "/storage/emulated/0/Download/.last_tmp.py" && exit
lated/0/Download/.last_tmp.py" && exit      <
Traceback (most recent call last):
  File "/storage/emulated/0/Download/.last_tmp.py", line 18, in <module>
    conexao = sqlite3.connect("banco.contato")
sqlite3.OperationalError: unable to open database file
1|whyred:/ $

1 answer

0


It is possible from Qpython version 1.0, but you need to define where to save the file. The error is indicating that you are not allowed to save in the place where you tried:

conexao = sqlite3.connect("/storage/emulated/0/Download/banco.contato")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.