How to add MySQLdb library into Python of XBMC?
#1
Anyone can help me please.... if it possible i would like the MySQLdb folder which can available to use in python code

Thank you
Reply
#2
I'm not sure I'd advise adding the library to XBMC, as you'll lose it every time you upgrade XBMC. You're much better off adding the library to your script and then importing it. I'm no expert at that, but based on what I did with Artist Slideshow, try this in your add on code (assuming that there is a directory called resources at the root of your add on):

Code:
__addon__        = xbmcaddon.Addon()
__addonname__    = __addon__.getAddonInfo('id')
__addonversion__ = __addon__.getAddonInfo('version')
__addonpath__    = __addon__.getAddonInfo('path').decode('utf-8')
__addonicon__    = xbmc.translatePath('%s/icon.png' % __addonpath__ )
__language__     = __addon__.getLocalizedString

...

sys.path.append( os.path.join( __addonpath__, "resources/MySQLdb" ) )

After that import the library the way you normally would. I was trying to find the MySQLdb package to see exactly how to do the import, but it didn't look like there were precompiled ones out there (at least that I could spot in a few minutes).

Hopefully that'll be enough to get you headed in the right direction, or at least enough for someone to correct what I've suggested. Smile
Reply
#3
Thank you for you suggest but i still cannot do it let me show the code that i have error

Code:
12:36:42 T:3348  NOTICE: -->Python Interpreter Initialized<--
12:36:42 T:3348   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.ImportError'>
                                            Error Contents: DLL load failed: The specified module could not be found.
                                            Traceback (most recent call last):
                                              File "C:\Users\HIBARI\AppData\Roaming\XBMC\addons\plugin-private-infotainment101\default.py", line 7, in <module>
                                                import MySQLdb
                                              File "C:\Program Files (x86)\XBMC\system\python\lib\site-packages\MySQLdb\__init__.py", line 19, in <module>
                                                import _mysql
                                            ImportError: DLL load failed: The specified module could not be found.
                                            -->End of Python script error report<--
12:36:42 T:4476   ERROR: XFILE::CDirectory::GetDirectory - Error getting plugin://plugin-private-infotainment101/
12:36:42 T:4476   ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin-private-infotainment101/) failed
12:36:42 T:6548  NOTICE: Thread Background Loader start, auto delete: false
Reply
#4
If I understand correctly you want to access a MySQL DB?
Then add to addon.xml:
Code:
    <requires>
        <import addon="xbmc.python" version="2.1.0"/>
        <import addon="script.module.myconnpy" version="0.3.2"/>
    </requires>

script.module.myconnpy contains the MySQL connectivity.
It's completly written in Python.

You can see the usage in MyPicsDB.
Especially within /rescoures/lib/dbabstractionlayer.py and /resources/libs/MypicsDB.py
No log no help.
Main page: https://github.com/Xycl
Repository: Xycl Repository Leia
Repository: Xycl Repository Matrix
Reply

Logout Mark Read Team Forum Stats Members Help
How to add MySQLdb library into Python of XBMC?0