pyobdc recipe for connecting to a MSSQL database

349 views
Skip to first unread message

Arn Rojas

unread,
Apr 27, 2020, 12:41:11 AM4/27/20
to Kivy users support
Hi everyone.
In my application I've implemented a pyobdc module to make querys to a MSSQL database, it works fine in my Linux Machine but when I compile it with buildozer to create the APK something goes wrong.
I realized that there is not a p4a recipe for this module so made a Fork of the python-for-android repository and created my own. This is the code of the __init__.py file that is inside the folder named pyobdc in the recipes directory:

from pythonforandroid.recipe import CompiledComponentsPythonRecipe

class PyodbcRecipe(CompiledComponentsPythonRecipe):
 
 version
= '4.0.30'
 url
= 'https://github.com/mkleehammer/pyodbc/archive/{version}.tar.gz'
 site_packages_name
= 'pyodbc'
 depends
= ['setuptools']
 
 call_hostpython_via_targetpython
= False
 install_in_hostpython
= False
 install_in_targetpython
= False
 
recipe
= PyodbcRecipe()

Included with this, I modified the . spec file to call this Fork.

p4a.fork = drarn96
p4a
.branch = develop

Now the compiler has recognized pyodbc as one of his own recipies.

At this point That is all what I know, that the recipe is being recognized, however I don't know if it is being created in the right way

I’m just sure of version, url and site_packages_name values, otherwise, I don’t know anything.

The actual error that I have is this:

/home/linuxlite/.buildozer/android/platform/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: warning: skipping incompatible /usr/local/lib/libodbc.so while searching for odbc
/home/linuxlite/.buildozer/android/platform/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9.x/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lodbc clang: error: linker command failed with exit code 1 (use -v to see invocation)
error
: command '/usr/bin/ccache' failed with exit status 1


It seems that pyobdc need a better configuration in the recipe class, because it's not finding an obdc. Maybe a driver has to be configured inside it, I don't know. I will be very thankful if I can get some advice, information of any kind or corrections because I've been reading the documentation and seeing how other recipes works but is not clear for me at all.


Robert Flatt

unread,
Apr 27, 2020, 1:09:57 AM4/27/20
to Kivy users support
For another time there is an easier way to do this, no need to fork, create a local recipe directory and put your recipe there.
I don't know if this will fix your issue, but it is easy to try, and even if it fails would narrow the issue.

Here, replace RECIPE_NAME with whatever recipe you are adding:

1) in buildozer.spec change this
#p4a.local_recipes =
to
p4a.local_recipes =  ./p4a-recipes

2) create directories
./p4a-recipes
./p4a-recipes/RECIPE_NAME

3) Put your __init__.py in  ./p4a-recipes/RECIPE_NAME

4) Add your recipe to Buildozer requirements

5) buildozer android clean

6) buildozer android debug

Arn Rojas

unread,
Apr 27, 2020, 1:35:52 AM4/27/20
to Kivy users support
Thanks, It helps me a lot, now is easier to make changes in recipes, but nevertheless the problem is still being the same. 

Robert Flatt

unread,
Apr 27, 2020, 4:37:22 PM4/27/20
to Kivy users support
This is probably not the best place to ask for help in writing recipes, not really a topic here.
So assuming you are back to the default p4a:

That said I wonder about those boolean flags, I expect you copied them from somewhere, but recipes I have looked at do not have them.
Also it looks like building libodbc.so for ARM is not happening, perhaps that should be a dependency in the recipe?
But then you have to use create a recipe for libodbc

Stepping back, does msqlclient to what you need?

hwcoll...@gmail.com

unread,
Sep 23, 2020, 9:50:06 PM9/23/20
to Kivy users support
Hi, I am having the same problem with you. My app can't be deployed because buildozer can't compile pyodbc with it.

Seeing that you are able to make a recipe for it, may I know if is is successful in your final build ?

Reply all
Reply to author
Forward
0 new messages