View Full Version : data from maya ta database (and vice versa)

01-14-2008, 03:21 PM
What is the best way to get data from inside a maya scene into a database (and vice versa)? Export separate .xml, read binary files, query sql via python? Any one tried?

01-14-2008, 06:41 PM
What is the best way to get data from inside a maya scene into a database (and vice versa)? Export separate .xml, read binary files, query sql via python? Any one tried?

We're on SQL here, so most of our db files are python sql calls. I'd think that xml would get really ugly really quickly, but I could be wrong.

01-14-2008, 09:06 PM
i think that MySQLdb has become the de-facto standard for database integration in maya.



01-14-2008, 09:13 PM
ok, thats good news.
Is there any way of getting information from maya binary files via python?

01-14-2008, 10:47 PM
i don't mean to imply that MySQLdb comes pre-installed with maya, only that it seems to be the most common solution.

as far as maya binary files, i'd be very interested in this if someone had a package to do it, but i believe your best option would be to use mayapy (the maya python interpreter which you can find in the maya bin dir) to open the file in batch (non-gui) mode and get the info you need.

01-14-2008, 10:57 PM
i give that a try tomorrow.
I played with the python sql some weeks ago and it seems its a pretty good thing.

01-15-2008, 05:09 PM
Works well so far.
Why use mayapy over any other python?

01-15-2008, 06:23 PM
honestly, i don't use it that often, but i would like to make better use of it. mayapy is just a little shell script that sets up some environment variables before calling the python interpreter in the maya application directory. these environment variables must be set before initiating the interperter if you want to have access to the functions in maya.cmds. the advantage of using mayapy is that you can work interactively with a maya session from the python command prompt. to get access to the commands you must first run:

import maya.standalone

however, if using pymel, you can just import the pymel module and all will be setup automatically for you, including parsing environment variables from your Maya.env.

so, once you have everything initialized, you can use almost all non-ui commands to do whatever you want. since using maya commandline is faster to startup, requires less resources, and is less invasive to the artist who may be running your script, it's perfect for performing tasks behind the scenes that could not be performed without maya, such as getting info from an mb file, since to my knowledge it cannot be parsed.

also, if you have an IDE or text editor that supports executing python commands, you can provide mayapy as your interpreter and run commands directly from your text editor.

01-15-2008, 06:37 PM
I use IDLE and do the intialize thing at the moment.
Does this call the mayapy.exe? I wasnt aware.
Just testing if it works at all at the moment.

CGTalk Moderation
01-15-2008, 06:37 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.