473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Python and MySQL

I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?

Nov 2 '05 #1
13 2012
[Aquarius]
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?


Possibly not want you want to hear, but I'd strongly recommend to stop
wasting your time with a hosting company that doesn't support the
technologies you need.

Instead, try a hosting company that supports python: there are lots and lots

http://wiki.python.org/moin/PythonHosting

Life's too short to spend your time hacking around artificial barriers
to progress.

--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan
Nov 2 '05 #2
Aquarius wrote:
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?

You'll definitely need something to call the database API functions, I
suspect.

You could do a *private* install of the module though, surely, on your
web host?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Nov 2 '05 #3
Aquarius wrote:
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?


I assume that MySQL clients talk to servers via sockets, and it should
be possible to write a python client that did that. It's probably some
work though, and it will probably piss MySQL AB off, since it means that
you could write MySQL client apps using whatever license you want
without paying them.

I wrote a prototype for such a client lib for PostgreSQL once, and it
was fairly simple, but the PostgreSQL docs have decent descriptions of
their protocol, while I assume MySQL hasn't since they want people to
use their client libs and pay for that. (If you read the client lib
source and translate that to Python, it should be considered a derivate,
and GPL applies. If you manage to get it to work without reading any
GPLed code, I guess you are entitled to use whatever license you want.)
Disclaimer: IANAL.
Nov 2 '05 #4
"Aquarius" <st**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?


Well, I'm looking at the source for the ever popular MySQLdb library. It
appears to be nothing but straight up Python source code. I see no reason
why you couldn't just take these modules and put them in your own private
directory. There is nothing secret here.

But

As others have already pointed out, after you go to this trouble, your
hosting provider will still suck! I'm sure you can you can get lot's of
suggestions for a suitable replacement.

Thomas Bartkus
Nov 2 '05 #5
Thomas Bartkus wrote:
"Aquarius" <st**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I appologize in advance for this strange (and possibly stupid)
question.

I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?

Well, I'm looking at the source for the ever popular MySQLdb library. It
appears to be nothing but straight up Python source code. I see no reason
why you couldn't just take these modules and put them in your own private
directory. There is nothing secret here.

But

As others have already pointed out, after you go to this trouble, your
hosting provider will still suck! I'm sure you can you can get lot's of
suggestions for a suitable replacement.

I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Nov 2 '05 #6
"Steve Holden" <st***@holdenweb.com> wrote in message
news:ma*************************************@pytho n.org...
Thomas Bartkus wrote:
Well, I'm looking at the source for the ever popular MySQLdb library. It
appears to be nothing but straight up Python source code. I see no reason
why you couldn't just take these modules and put them in your own private directory. There is nothing secret here.

I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?


You made me give that library a good hard stare.

And no - everything is enunciated in clear Python (.py) code with
corresponding (.pyc) and (.pyo). It appears we have Python source for
everything.

FWIW:
print MySQLdb.version_info

(1, 2, 0, 'final', 1)

There doesn't seem to be .c code to be found anywhere.
Thomas Bartkus
Nov 2 '05 #7
Thomas Bartkus wrote:
"Steve Holden" <st***@holdenweb.com> wrote in message
news:ma*************************************@pytho n.org...
Thomas Bartkus wrote:
Well, I'm looking at the source for the ever popular MySQLdb library. It
appears to be nothing but straight up Python source code. I see no
reason
why you couldn't just take these modules and put them in your own
private
directory. There is nothing secret here.


I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?

You made me give that library a good hard stare.

And no - everything is enunciated in clear Python (.py) code with
corresponding (.pyc) and (.pyo). It appears we have Python source for
everything.

FWIW:

print MySQLdb.version_info


(1, 2, 0, 'final', 1)

OK. I saw that my own version was (1, 0, 0, 'final', 1), so I assumed
Andy's updated the package somewhat. However, downloading the source of
1.2 I see that _mysql.c still appears, and that the package's
__init__.py still includes the line

include _mysql

My C:\Python24\Lib\site-packages directory does contain a _mylsql.pyd
file. Would you like to check that we are talking about the same module?

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Nov 3 '05 #8
I am also have _mysql.c that has to be compiled. I downloaded 1.2.0
from here
http://sourceforge.net/project/showf...ckage_id=15775
(the .tar.gz). Do you mean, that if I drop the import _mysql and from
_mysql import ... lines everything will work OK? I "private install"
would be great for me, if it works :D

Nov 3 '05 #9
Aquarius <st**********@gmail.com> wrote:
I want to know if there is a way to interface a MySQL database without
Python-MySQL or without installing anything that has C files that need
to be compiled. The reason for this, is that I want to develop a
certain web application, but my hosting provider (!#@$!@#%) isn't very
eager to supply Python-MySQL (or any modules to python). Is there an
alternative approach I could use to pass around this ridiculos lack of
functionality?


If you've got MySQL installed, you probably have a command-line
mysql client, and you could use subprocess or popen to run that.
That's a little desperate though, and the error handling will suck.
(I've seen this trick used with other databases.)

--
\S -- si***@chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomež se bera eadward ofdun hlęddre heafdes bęce bump bump bump
Nov 3 '05 #10
"Steve Holden" <st***@holdenweb.com> wrote in message
news:ma*************************************@pytho n.org...
Thomas Bartkus wrote:
"Steve Holden" <st***@holdenweb.com> wrote in message
news:ma*************************************@pytho n.org...
I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?

You made me give that library a good hard stare.

And no - everything is enunciated in clear Python (.py) code with
corresponding (.pyc) and (.pyo). It appears we have Python source for
everything.

FWIW:

>print MySQLdb.version_info


(1, 2, 0, 'final', 1)

OK. I saw that my own version was (1, 0, 0, 'final', 1), so I assumed
Andy's updated the package somewhat. However, downloading the source of
1.2 I see that _mysql.c still appears, and that the package's
__init__.py still includes the line

include _mysql

My C:\Python24\Lib\site-packages directory does contain a _mylsql.pyd
file. Would you like to check that we are talking about the same module?


Okay - I neglected to look at the [site-packages] directory itself. Here I
do find [_mysql.pyd] full of binary code. A MySQLdb related file that
doesn't seem to have a corresponding file with Python source code. Mea
culpa! This is on MS Windows [C:\Python23].

But heck! Now I'm looking at the /usr/lib/python2.3/site-packages on a
Mandrake Linux box. No [_mysql.] pyd here! Fewer files overall and while
there are other file extensions, everything seems to have a corresponding
[.py].

print MySQLdb.version_info
(0, 9, 2, 'final', 1)

Thomas Bartkus

Nov 3 '05 #11
Thomas Bartkus wrote:
[some posters having the idea that MySQLdb works without a C extension]
Okay - I neglected to look at the [site-packages] directory itself. Here I
do find [_mysql.pyd] full of binary code. A MySQLdb related file that
doesn't seem to have a corresponding file with Python source code. Mea
culpa! This is on MS Windows [C:\Python23].

But heck! Now I'm looking at the /usr/lib/python2.3/site-packages on a
Mandrake Linux box. No [_mysql.] pyd here! Fewer files overall and while
there are other file extensions, everything seems to have a corresponding
[.py].


MySQLdb is based on a C extension module called _mysql on all platforms.
The C extension modules have the extension ".pyd" on Windows by default,
and ".so" on Unix.

It would in theory be possible to do without a C extension, but then you
would have to implement the MySQL client-server protocol
(http://dev.mysql.com/doc/internals/e...-protocol.html) in
Python, for example using the socket module.

Implementing a pure-Python package to interface a database by
implementing the client-server protocol in Python has been done already
for PostgreSQL, but I don't think it has been done for MySQL, yet.

-- Gerhard

Nov 3 '05 #12
Thomas Bartkus wrote:
But heck! Now I'm looking at the /usr/lib/python2.3/site-packages on a
Mandrake Linux box. No [_mysql.] pyd here! Fewer files overall and while
there are other file extensions, everything seems to have a corresponding
[.py].


I suspect you might find _mysql.so there. If you find any .pyd files I
think you can safely remove them, since Windows DLLs work poorly in
Linux anyway. Aren't you starting to suspect that you don't really know
what you are talking about in this particular case? Where is the pure
Python code that actually communicates with the database server? Have
you found a single line of code that actually does that? How does it
communicate? Isn't there an 'import _mysql' somewhere? Where is the
_mysql.py then?

What's this?
http://cvs.sourceforge.net/viewcvs.p...SQLdb/_mysql.c

What's this doing in setup.py?
'ext_modules': [
Extension(
name='_mysql',
sources=['_mysql.c'],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
extra_objects=extra_objects,
),
],
Nov 3 '05 #13
"Magnus Lycka" <ly***@carmen.se> wrote in message
news:dk**********@wake.carmen.se...
Thomas Bartkus wrote:
But heck! Now I'm looking at the /usr/lib/python2.3/site-packages on a
Mandrake Linux box. No [_mysql.] pyd here! Fewer files overall and while there are other file extensions, everything seems to have a corresponding [.py].
I suspect you might find _mysql.so there. If you find any .pyd files I
think you can safely remove them, since Windows DLLs work poorly in
Linux anyway. Aren't you starting to suspect that you don't really know
what you are talking about in this particular case?


Yes!

And thank you so much for pointing that out :-)
Thomas Bartkus
Where is the pure
Python code that actually communicates with the database server? Have
you found a single line of code that actually does that? How does it
communicate? Isn't there an 'import _mysql' somewhere? Where is the
_mysql.py then?

What's this?
http://cvs.sourceforge.net/viewcvs.p...SQLdb/_mysql.c

What's this doing in setup.py?
'ext_modules': [
Extension(
name='_mysql',
sources=['_mysql.c'],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries,
extra_compile_args=extra_compile_args,
extra_objects=extra_objects,
),
],

Nov 3 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Yong Wang | last post by:
Hi, All: We have a network management system written in C++, MysQL, and Hp SNMP. It works in Solaris command line. When I wrote a similar python codes which call compiled C++ and mysql codes in...
2
by: francescomoi | last post by:
Hi. I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2: ---------------------------------- # export PATH=$PATH:/usr/local/mysql/bin/ # export mysqlclient=mysqlclient_r # python setup.py...
2
by: Cathy Hui | last post by:
I am trying to install MySQL-Python 0.9.1 on my Solaris 8 system. The system has Python 2.3.3 and Mysql 4.0.21 installed. This is where I downloaded the distribution of the Mysql-python...
2
by: Cathy Hui | last post by:
Do u know why do i get the following message when trying to build the MySql-Python (1.2.0) on my Solaris 8 system? (with mysql 4.0.21 and python 2.4). thanks! error mesg: ld: fatal:...
10
by: callmebill | last post by:
I'm getting my feet wet with making Python talk to MySQL via ODBC. I started on Windows, and it went smoothly enough due to the ODBC stuff that apparently is native to Python at least on windows...
2
by: Richard Brosnahan | last post by:
I hate asking questions that have probably been answered before, but I have not found a way to conveniently search the archives of this mailing list. So... Can someone tell me how to...
16
by: bobrik | last post by:
Hello, I am using the Python DB API for access to MySQL. But it is not platform-independent - I need a module not included in Python by default - python-mysql, and it uses a compiled binary...
113
by: John Nagle | last post by:
The major complaint I have about Python is that the packages which connect it to other software components all seem to have serious problems. As long as you don't need to talk to anything outside...
13
by: Steven Bethard | last post by:
Jean-Paul Calderone <exarkun@divmod.comwrote: Interesting. Could you give a few illustrations of this? (I didn't run into the same problem at all, so I'm curious.) Steve
1
by: Steve Ametjan | last post by:
I've been trying to get MySQL-python to install on Leopard for the past couple of days, and I keep running into relatively the same error. I'm hoping that someone on this list will be able to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.