MySQL Forums
Forum List  »  Connector/Python

Re: MySQL-python on Solaris (solved!)
Posted by: stefan sonnenberg
Date: July 28, 2006 11:28AM

setup.py tries to determine your build settings.
ActiveState Python is built using SunCC.
You have gcc :)
See the output from disutils.sysconfig.get_config_vars()

With ASpy23 it works after changing in site.cfg
threadsafe = True
to
threadsafe = False

For ASpy24 do this:
in the file _mysql.c insert these lines:

#define version_info "(1,2,1,'final',2)"
#define __version__ "1.2.1_p2"

Somewhere right after the copyright notice.

enter:
python setup.py build
!!! It will fail, don't care !!!

enter:
gcc -I/usr/local/mysql/include/mysql -I/opt/ASpy24/include/python2.4 -c _mysql.c -o build/temp.solaris-2.9-sun4u-2.4/_mysql.o
!!! Check your local paths !!!

enter:
gcc -G build/temp.solaris-2.9-sun4u-2.4/_mysql.o -L/usr/local/mysql/lib/mysql -lmysqlclient -lz -lposix4 -lgen -lsocket -lnsl -lm -o build/lib.solaris-2.9-sun4u-2.4/_mysql.so
!!! Check your local paths !!!

enter:
python setup.py install

test:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib/mysql/:/opt/sfw/gcc-3/lib/
bash-2.05# python
ActivePython 2.4.3 Build 11 (ActiveState Software Inc.) based on
Python 2.4.3 (#1, Apr 3 2006, 18:34:02) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> dir(MySQLdb)
['BINARY', 'Binary', 'Connect', 'Connection', 'DATE', 'DATETIME', 'DBAPISet', 'DataError', 'DatabaseError', 'Date', 'DateFromTicks', 'Error', 'FIELD_TYPE', 'ImmutableSet', 'IntegrityError', 'InterfaceError', 'InternalError', 'MySQLError', 'NULL', 'NUMBER', 'NotSupportedError', 'OperationalError', 'ProgrammingError', 'ROWID', 'STRING', 'TIME', 'TIMESTAMP', 'Time', 'TimeFromTicks', 'Timestamp', 'TimestampFromTicks', 'Warning', '__all__', '__author__', '__builtins__', '__doc__', '__file__', '__name__', '__path__', '__revision__', '__version__', '_mysql', 'apilevel', 'connect', 'connection', 'constants', 'debug', 'escape', 'escape_dict', 'escape_sequence', 'escape_string', 'get_client_info', 'paramstyle', 'release', 'result', 'server_end', 'server_init', 'string_literal', 'thread_safe', 'threadsafety', 'times', 'version_info']
>>> con = MySQLdb.connect("localhost","root","")
>>> con
<_mysql.connection open to 'localhost' at 1fe008>
>>> cursor = con.cursor()
>>> cursor
<MySQLdb.cursors.Cursor object at 0x1950d0>
>>> res = cursor.execute("show databases")
>>> rows = cursor.fetchall()
>>> for row in rows:
... print row
...
('information_schema',)
('mysql',)
('test',)
>>> ^D


As you can see:
Switching compilers is a hurdle, but managable.
You could have SunCC installed (it's free) and would have been up and
running in minutes.

Cheers



Edited 3 time(s). Last edit at 07/31/2006 02:11AM by stefan sonnenberg.

Options: ReplyQuote


Subject
Written By
Posted
November 10, 2005 09:04AM
April 10, 2006 01:07AM
Re: MySQL-python on Solaris (solved!)
July 28, 2006 11:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.