PyMsSql on kivy.

841 views
Skip to first unread message

hci...@gmail.com

unread,
May 23, 2013, 1:33:24 PM5/23/13
to kivy-...@googlegroups.com
I'm trying to package an app for android that will be using pymssql to communicate with sql server. I'm having some trouble getting the right files into the directory. I'm not sure if I should just place the source files in the same directory as my main.py or if I should put them in a directory under python-for-android or in one of the kivy directories. It doesn't seem to recognize the .pyd or .pyx files that pymssql comes with and I can only find one .py that it includes but it needs '_mssql' and 'pymssql' to run. This was so easy to do under windows but I don't know where to start installing a third party library on an android from linux. Has anyone installed a third party library like this that could give some pointers?

Akshay Arora

unread,
May 23, 2013, 1:40:33 PM5/23/13
to kivy-...@googlegroups.com


On Thu, May 23, 2013 at 11:03 PM, <hci...@gmail.com> wrote:
I'm trying to package an app for android that will be using pymssql to communicate with sql server. I'm having some trouble getting the right files into the directory. I'm not sure if I should just place the source files in the same directory as my main.py or if I should put them in a directory under python-for-android or in one of the kivy directories. It doesn't seem to recognize the .pyd or .pyx files that pymssql comes with and I can only find one .py that it includes but it needs '_mssql' and 'pymssql' to run. This was so easy to do under windows but I don't know where to start installing a third party library on an android from linux. Has anyone installed a third party library like this that could give some pointers?

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

hci...@gmail.com

unread,
May 23, 2013, 2:17:59 PM5/23/13
to kivy-...@googlegroups.com
Thanks for the timely reply. I'm having a little bit of trouble wrapping my head around that though. I understand how I can get to the point of creating the recipe.sh but I don't know what to put in it. That document doesn't describe what python-for-android needs in a recipe. Is there a doc or tutorial that describes this? I also assume that each library is going to have different directory structures? Which file type does it require to have in the module directory .py, .pyc, .pyx, .pyo or .so? Thanks again!

Akshay Arora

unread,
May 23, 2013, 3:21:31 PM5/23/13
to kivy-...@googlegroups.com
Just open up recipe.sh.tmpl, it's a template of what your recipe.sh ought to be like. 

Then open up one of the previously supplied recipes folders to see how they are setup. Basically using recipe.sh you are supposed to provide details like download url, pre build setup procedure... patches... etc, commands to build and post build procedure required. 

The folder for your recipe should contain a recipe.sh along with any extra files like patches that aren't part of the downloaded files that are required to build the module.

Best Regards


hci...@gmail.com

unread,
May 23, 2013, 4:45:10 PM5/23/13
to kivy-...@googlegroups.com
Thanks! What if that URL is an executable that runs its own install. Will the recipe be able to redirect where the files are supposed to land? I'm still foggy about what files are supposed to go where because I don't know where python-for-android will be looking for the modules when it builds the app.

Thomas Pietrowski

unread,
May 24, 2013, 3:18:31 AM5/24/13
to kivy-...@googlegroups.com
I already made a recipe for the mysql connector, maintained by Oracle. It works fine with my app.

You'll need to run: ./distribute -m 'mysql_connector kivy'
Depending how I named this recipe ;-)

If I wrong check ./distribute -l

hci...@gmail.com

unread,
May 24, 2013, 11:11:06 AM5/24/13
to kivy-...@googlegroups.com

That's cool! does that mean that the recipe for pymssql will be a similar setup. I wish I could use mysql on this project but our company is fully on mssql server. I've never made anything like a recipe before (I usually just stick to Python) so I'm not even sure what I'm looking at when I open one up. The documentation on the link above is also difficult to follow. I'm still confused about what file types Python-For-Android is looking for and where they go.

Ben Rousch

unread,
May 24, 2013, 11:23:39 AM5/24/13
to kivy-...@googlegroups.com
If I can be "that guy" for a moment ... In general your Android app
should not be directly accessing your remote database. An app should
access an API or service on top of that database. Your app then only
needs to understand how to interact with that API via (typically)
SOAP, XML-RPC, REST, or just JSON.
> --
> You received this message because you are subscribed to the Google Groups
> "Kivy users support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to kivy-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Ben Rousch
bro...@gmail.com
http://clusterbleep.net/

hci...@gmail.com

unread,
May 24, 2013, 11:27:56 AM5/24/13
to kivy-...@googlegroups.com
I'd also like to add that beyond importing pymssql and using its fuctions in my program I know nothing about its build structure and I don't know anything about python-for-android other than how to build an .apk using it. It seems to me that I would have to have the intimate knowledge that one of the developers on both ends of these two packages has to be able to write a recipe for this one package. Am I just not understanding how this works? Is it really simpler than all that? I really need to get this going, it's the last step we need to go through before we can release our software.

hci...@gmail.com

unread,
May 24, 2013, 11:34:47 AM5/24/13
to kivy-...@googlegroups.com

Sorry my last response was being typed while you were sending yours. I agree with what you say for a normal use of the android system (IE a phone's data package). Our system though is running directly within our local network and just happens to be the android platform. They're really running just the same way a normally networed computer terminal would. Just think of it as an integrated touchscreen device. Anyway architecture aside I really just need some pointers on building a recipe for pymssql because that's what we're using.

hci...@gmail.com

unread,
May 28, 2013, 11:26:44 AM5/28/13
to kivy-...@googlegroups.com
So what do you guys think? Can anyone help with this?

hci...@gmail.com

unread,
May 28, 2013, 4:27:34 PM5/28/13
to kivy-...@googlegroups.com
The problem I'm having is that under windows when I put the pymssql.pyd and _mssql.pyd in the same folder as my main.py kivy runs it just fine. Under Linux the pymssql.(pyc) and _mssql.(so) files are kept under /usr/lib/python2.7/modules and this allows python to use pymssql. I've been trying to mirror this in python-for-android. I've put these two files under every folder I can find that is named 'modules'. This doesn't work. I some cases it ruins my other perfectly viable imports that always worked before. It seems to me that when PFA compiles my project it takes every .py and compiles it to a .pyo no matter where it is. That's great for pure python files but what about cython files? How do I get PFA to recognize these as modules?  

Kovak

unread,
May 28, 2013, 11:20:32 PM5/28/13
to kivy-...@googlegroups.com
For cython modules take a look at the recipe for cymunk that comes in the python for android distribution

hci...@gmail.com

unread,
May 29, 2013, 12:18:26 PM5/29/13
to kivy-...@googlegroups.com
Thank you, that gets me a step closer. Am I understanding that I need .pyx or .o files to be in the site-packages directory under PFA? Would that be the one that's in the directory under 'build' for 'python 2.7' or one of the other site-packages folders? What happens with .so file types, are they not used by kivy? If all it is that the .pyx files need to be under site-packages why can't I just drag and drop them there? Also how do I run the recipe once it's been written? And finally where can you direct me to a good tutorial that thoroughly explains build and shell scripts (Having a hard time wrapping my head around the language). Sorry for all the questions its just that I generally stick to the programming portion of a project and usually don't do anything with shell scripts especially not on Linux (Can't wait to get my hands in this though). 

hci...@gmail.com

unread,
Jun 3, 2013, 10:54:59 AM6/3/13
to kivy-...@googlegroups.com
Bump?

hci...@gmail.com

unread,
Jun 4, 2013, 5:34:45 PM6/4/13
to kivy-...@googlegroups.com

I hate to be the guy that keeps on asking but I really need this question answered. We have our software finished which represents hundreds of hours of development and we have a presentation to make this Friday. All I need is for this one third party module to be included in the final build for Android. I am not getting anywhere with the recipes because the documentation is very limited. Is there a way I could get an experienced recipe script writer's advice on how I can get this third party module from point A to point B? Again this is very important, I really need the help. Thanks.

Thomas Pietrowski

unread,
Jun 4, 2013, 6:01:06 PM6/4/13
to kivy-...@googlegroups.com
Well, as I answered before.. You can use the MySQL-Connector for Python. It is written in pure Python and can be executed on every platform where Python is available:

I made the recipe and I'm also using it in my App:


.. and take a look on other recipes on git. You might find a recipe which needs just some modifications to make your job. (In case you don't want to use the MySQL-Connector)

In case you browse the web for code samples for the MySQL-Connector double check which version they where running.. I remember some of them were not working when I started coding using the Connector.
(Can send you some code I use to sync a SQL db on the phone with a MySQL server. I still keep this code closed source, for security reasons.)

Finally, you can build this module together with kivy via:
./distribute -m "kivy mysql_connector"

The next 12 hours I'll be busy as I have to work for a project and I have to spend now my night for it. Feel free to give some feedback, but don't expect that someone will make PyMySQL working for you. I tried it before and I was happy to find Oracle's alternative to it.

Regards,
Thomas-Karl Pietrowski



2013/6/4 <hci...@gmail.com>

I hate to be the guy that keeps on asking but I really need this question answered. We have our software finished which represents hundreds of hours of development and we have a presentation to make this Friday. All I need is for this one third party module to be included in the final build for Android. I am not getting anywhere with the recipes because the documentation is very limited. Is there a way I could get an experienced recipe script writer's advice on how I can get this third party module from point A to point B? Again this is very important, I really need the help. Thanks.

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/IQijU7V7UEs/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.

hci...@gmail.com

unread,
Jun 4, 2013, 6:07:29 PM6/4/13
to kivy-...@googlegroups.com
Thank you for the quick reply. Do I understand right that it's not possible to use pymssql with kivy on android? This would be bad because we only have a ms sql server at our company. Am I understanding that you can use the mysql connector with a ms sql server? If so how is that done?

Thomas Pietrowski

unread,
Jun 4, 2013, 6:18:08 PM6/4/13
to kivy-...@googlegroups.com
Thats right. You can use the MySQL-Connector. Well, Oracle is developing the MySQL Server and also provides the module for Python I use for my project.
I also own a PPA on launchpad providing the latest version of that module, in case you use Ubuntu/Debian for developing your software.

The difference between PyMySQL and MySQL-Connector is that PyMySQL needs architecture-dependent binary code to run (and libmysqlclient and other dependencies), but MySQL connector just needs python and its default module set and thats all.

There is no more work to be done. Just code your app on a PC (where Python2.7, kivy and the MySQL-Connector is installed), design your app, make it do your job and finally use the MySQL-Connector to connect to your MySQL-server.

Just take a look at the reference I send you before. It will give the most of the answers you have ;)



2013/6/4 <hci...@gmail.com>
Thank you for the quick reply. Do I understand right that it's not possible to use pymssql with kivy on android? This would be bad because we only have a ms sql server at our company. Am I understanding that you can use the mysql connector with a ms sql server? If so how is that done?

hci...@gmail.com

unread,
Jun 4, 2013, 6:36:07 PM6/4/13
to kivy-...@googlegroups.com
Okay, actually I'm using a mssql server as in microsoft server not a mysql server. We don't use Oracle products. So my question is will the oracle connector work with a microsoft server?

Thomas Pietrowski

unread,
Jun 4, 2013, 6:53:37 PM6/4/13
to kivy-...@googlegroups.com
I'm sorry. I misunderstood that you've got MySQL running.. Just thought all the time you mistyped it..
Well, as far as I can looked now on the documentation of this module I think it might be as easy as building Kivy for Android..
But, except of the FreeTDS library which is needed for PyMsSQL!

So, as I told you before. Take a look at other recipes and try to make your module get build. Prepare a code example to test the module at the end.
How much, money would you invest in getting a working recipe?


2013/6/4 <hci...@gmail.com>
Okay, actually I'm using a mssql server as in microsoft server not a mysql server. We don't use Oracle products. So my question is will the oracle connector work with a microsoft server?

Ben Rousch

unread,
Jun 4, 2013, 7:00:33 PM6/4/13
to kivy-...@googlegroups.com
I wish I could help, but I don't have a MS SQL server, or even Windows
to run it on. Maybe you could put an XML-RPC or RESTFUL API between
the SQL server and the network? If you do so, it becomes trivial to
use it from any kind of client.
> You received this message because you are subscribed to the Google Groups
> "Kivy users support" group.
> To unsubscribe from this group and stop receiving emails from it, send an

hci...@gmail.com

unread,
Jun 4, 2013, 7:31:02 PM6/4/13
to kivy-...@googlegroups.com
How much, money would you invest in getting a working recipe?

I'm not in charge of outsourcing.

Would the FreeTDS need to be on the device for it to work or do I just need this for when the recipe compiles the module?

Gabriel Pettier

unread,
Jun 4, 2013, 7:30:58 PM6/4/13
to kivy-...@googlegroups.com
I would +1 on this, even if it's an internal use, it's not a very good
idea to have sql over network, i believe.

hci...@gmail.com

unread,
Jun 4, 2013, 7:54:14 PM6/4/13
to kivy-...@googlegroups.com

Actually the enterprise system we and hundreds of other corperations use for record keeping uses sql over network to pass very large amounts of data so we feel very safe with this paradime. I'm just wandering about the FreeTDS question, is that going to cause an issue when compiling?  

hci...@gmail.com

unread,
Jun 6, 2013, 11:15:19 AM6/6/13
to kivy-...@googlegroups.com
Thank you all for your help on this. I was finally able to convince my boss to get me a MySQL server and now the last link of the project has been realized. Thank you Thomas for your recipe.   

Jasmal Py

unread,
Aug 12, 2015, 2:26:19 AM8/12/15
to Kivy users support

John Fabiani

unread,
Aug 12, 2015, 11:15:28 AM8/12/15
to Kivy users support
Since you are going to use direct connections to mysql you might want to review the postgres using p8000.py.  We have used it with success and it is pure python (not even ctypes is required).  Like you we discovered that we could not find a way to directly connect to mssql and ended up using Flask restful api to allow the data transfer.  Flash was very easy to use and took only a few hours to setup.

Johnf
Message has been deleted

allaboutmike

unread,
Feb 26, 2019, 7:36:47 PM2/26/19
to Kivy users support
Apologies for necro bumping this old thread, but it comes up first in the google search for this topic. The situation has obviously changed since this thread was active and this is one of the few places I could find it mentioned.
I had the same issues with pymssql and similar requirements (low security concern, local database). As of early 2019, pymssql is still not able to be included in a kivy project for android. I suppose the demand is not great enough for anyone to get around to writing a recipe. However, python-tds (pure python module) works for me with SQL Server 2014 from an android device. I just had to add python-tds in the requirements list for buildozer and make a couple of very minor code changes to suit pytds instead of pymssql. No recipe required. It doesn't seem to make any noticable performance difference either.
Reply all
Reply to author
Forward
0 new messages