??? sqlite3 and buildozer ???

314 views
Skip to first unread message

Peter Peter

unread,
Jan 2, 2019, 7:11:39 PM1/2/19
to Kivy users support
Hello, 

Is it possible to work with sqlite3, kivy and buildozer or there is an unsolving issue working with these until now ?

I get the no module found '_sqlite3' error.

I spent so much time lookig for solutions on this forum and internet ... quite deseparate... I'm stuck...

I will appreciate your help a lot !  ;-)

JC

unread,
Jan 4, 2019, 3:09:19 AM1/4/19
to Kivy users support


Peter,

it works flawlessly in my case using VM 0.5. to build app for Android.

I can  share my buildozer.spec if you wish, but has nothing special.

JC

Peter Peter

unread,
Jan 6, 2019, 3:27:48 PM1/6/19
to Kivy users support
yes why not, I will try.

You can build an app with sqlite3 import? 

JC

unread,
Jan 7, 2019, 5:17:12 AM1/7/19
to Kivy users support



This works for me


from kivy.logger import Logger
from kivy.utils import platform
import sqlite3
import time
import os
import socket

conn
=None
#####################################################################

def dbInitConnection():
   
global conn
   
if socket.gethostname()=="portatilU":
        DB
="/home/julian/tmp/sqlite/nevera.sqlite3"
   
else:
        DB
="nevera.sqlite3"
   
   
if os.path.exists(os.path.normpath(DB)):
        conn
=sqlite3.connect(DB)
   
else:
        conn
=sqlite3.connect(DB)
        c
=conn.cursor()
        c
.execute("""
                  CREATE TABLE "
nevera" (
    `id`    INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
    `contenido`    TEXT,
    `caduca`    TEXT NOT NULL,
    `precio`    REAL,
    `super`    TEXT,
    `peso`    REAL,
    `fcompra`    NUMERIC NOT NULL,
    `consumido`    TEXT,
    `tipo`    TEXT NOT NULL,
    `image`    TEXT,
    `thumbnail`    TEXT
)
                  """
)
        conn
.commit()
       
Logger.error("DB: database created")
       
       
#####################################################################

def dbGetItems(sel=None,consumido=False):
   
"""
       "
select * from  nevera where consumido='' and tipo='ave' order by fcompra"
    """

   
global conn
    conn
.row_factory = sqlite3.Row
    c
=conn.cursor()
   
    query
="select * from nevera "
   
   
if not consumido :
        query
+= "where  consumido is NULL "
   
else :
        query
+= "where  consumido is NOT NULL"
   
   
if sel:
        query
+=" and tipo=? order by fcompra"
       
#print("query {} sel {} ".format(query,sel))
        retval
=c.execute(query,(sel,)).fetchall()
   
else:
        query
+="  order by fcompra"
       
#print("query {} sel {} ".format(query,sel))
        retval
=c.execute(query).fetchall()
       
    retval
=[{y: x[y] for y in x.keys()}  for x in  retval]

   
return retval

#####################################################################
   
def dbUpdateConsumido(id):
   
global conn
    c
=conn.cursor()
    query
="update nevera set consumido=? where id==?"
    c
.execute(query,(time.strftime("%Y-%m-%d"),int(id),))
    conn
.commit()
   
return None
   
#####################################################################    
   
def dbRestore(id):
   
global conn
    c
=conn.cursor()
    query
="update nevera set consumido=? where id==?"
    c
.execute(query,(None,int(id),))
    conn
.commit()
   
return None

#####################################################################    
   
def dbInsert(data):
   
global conn
    keys
=["contenido","caduca","precio","super","peso","fcompra","tipo","image","thumbnail"]
    c
=conn.cursor()
    query
="""insert into nevera
    (contenido,caduca,precio,super,peso,fcompra,tipo,image,thumbnail)
    values (?,?,?,?,?,?,?,?,?)"""

   
   
    c
.execute(query,[data[x] for x in keys])
    conn
.commit()
   
   
return None


with buildozer deps  requirements = python2, kivy==1.10, sqlite3,plyer




I believe this is it for my simple app. This is the db access functions

Peter Peter

unread,
Jan 7, 2019, 7:36:02 AM1/7/19
to Kivy users support
this line: "with buildozer deps  requirements = python2, kivy==1.10, sqlite3,plye"
is a part of the spec file, we agree not python code?

Why python2 in the requirements? Do I have to put it even if I use python3 to program?

JC

unread,
Jan 7, 2019, 12:20:34 PM1/7/19
to Kivy users support

In my case I use https connections and I am forced to use python 2 in order to use SSL. SSL is not implemented in python3/Kivy as far as I know.

JC

unread,
Jan 7, 2019, 12:41:11 PM1/7/19
to Kivy users support


....and regrettably yes.... it fails for me as well if I try to make it python3 compatible + sqlite.

My code is essentially python3.5+ save a minor details to avoid issues with python3.  I take out the network stuff due to SSL to leave it as a plain python3/sqlite and it fails.

Different errors tough.


unzip:  cannot find zipfile directory in one of /home/kivy/nevera/.buildozer/android/platform/build/packages/kivy/1.10.zip or
       
/home/kivy/nevera/.buildozer/android/platform/build/packages/kivy/1.10.zip.zip, and cannot find /home/kivy/nevera/.buildozer/android/platform/build/packages/kivy/1.10.zip.ZIP, period.



JC

unread,
Jan 7, 2019, 12:41:30 PM1/7/19
to Kivy users support


....and regrettably yes.... it fails for me as well if I try to make it python3 compatible + sqlite.

My code is essentially python3.5+ save a minor details to avoid issues with python3.  I take out the network stuff due to SSL to leave it as a plain python3/sqlite and it fails.

Different errors tough.


unzip:  cannot find zipfile directory in one of /home/kivy/nevera/.buildozer/android/platform/build/packages/kivy/1.10.zip or
       
/home/kivy/nevera/.buildozer/android/platform/build/packages/kivy/1.10.zip.zip, and cannot find /home/kivy/nevera/.buildozer/android/platform/build/packages/kivy/1.10.zip.ZIP, period.





On Monday, 7 January 2019 18:20:34 UTC+1, JC wrote:
Reply all
Reply to author
Forward
0 new messages