PDA

View Full Version : selectively import MySQLdb (32 or 64 bit) from Maya


jojanpm
01-27-2011, 07:45 AM
A tool is being developed in Maya (using Python) for the entire company. Some people use 64-bit Maya while others, 32-bit.
I have to connect from this tool to MySQL server, from inside their Maya.
I have got MySQLdb libraries for both 32 and 64 bits, and both are working fine.

The problem is: How can i write code to decide which MySQLdb module (32 or 64 bit) needs to be imported according to the Maya version in the user's machine? I know the command 'about -v' and tried it by putting 32 and 64 bit versions of MySQLdb in mysql32bit and mysql64bit packages in the server (for e.g; my machine. They are accessing the script from my machine) separately. But didnt work; only errors. Is there any solution?
Please ask if any part is not clear.

haggi
01-27-2011, 10:02 AM
To use 32 and 64 bit python you need two installations of python and two libraries.

I would simply add the correct pythonpath in the maya.env file.
This way you always automatically import the correct modules.

flaiver
01-27-2011, 11:13 AM
you can use the about command to find out which version is in use

jojanpm
01-27-2011, 12:13 PM
no no.. u havent got me.
the script folder path (in server) has been added to users' Maya.env as PYTHONPATHs. and this path contain both libraries for 32 and 64 bit MySQLdb (i separated both into two different folders there, say mysql32 and mysql64, and added __init__.py inside each to make them modules), thts ok.
now, in the code which they should run in Maya, i imported either mysql32.MySQLdb or mysql64.MySQLdb according to their Maya version (used 'about -v' here).
But getting error in 'import _mysql' , so and so..
How can i escape from these errors in the easiest way?

NateH
01-27-2011, 09:47 PM
I got around a similar problem with 32 and 64 bit versions of PyQt by putting each site package in a zip file, and unzipping/adding the path at startup.

haggi
01-27-2011, 10:10 PM
You should have one 32bit lib and 64bit lib directory.

Then adding the correct script in the maya.env to the path should solve all problems. Lets say you have a directory called c:/pythonlib/mysql64 and one called c:/pythonlib32 then simply include the correct version in your maya.env.

Seems I still dont understand the problem yet.

CGTalk Moderation
01-27-2011, 10:10 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.