Python and MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aquarius

    #1

    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?

  • Alan Kennedy

    #2
    Re: Python and MySQL

    [Aquarius][color=blue]
    > 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?[/color]

    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



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

    --
    alan kennedy
    ------------------------------------------------------
    email alan: http://xhaus.com/contact/alan

    Comment

    • Steve Holden

      #3
      Re: Python and MySQL

      Aquarius wrote:[color=blue]
      > 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?
      >[/color]
      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/

      Comment

      • Magnus Lycka

        #4
        Re: Python and MySQL

        Aquarius wrote:[color=blue]
        > 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?[/color]

        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.

        Comment

        • Thomas Bartkus

          #5
          Re: Python and MySQL

          "Aquarius" <stefan.kanev@g mail.com> wrote in message
          news:1130948507 .082484.199730@ f14g2000cwb.goo glegroups.com.. .[color=blue]
          > 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?[/color]

          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


          Comment

          • Steve Holden

            #6
            Re: Python and MySQL

            Thomas Bartkus wrote:[color=blue]
            > "Aquarius" <stefan.kanev@g mail.com> wrote in message
            > news:1130948507 .082484.199730@ f14g2000cwb.goo glegroups.com.. .
            >[color=green]
            >>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 ?[/color]
            >
            >
            > 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.
            >[/color]
            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/

            Comment

            • Thomas Bartkus

              #7
              Re: Python and MySQL

              "Steve Holden" <steve@holdenwe b.com> wrote in message
              news:mailman.44 .1130970219.187 01.python-list@python.org ...[color=blue]
              > Thomas Bartkus wrote:[color=green]
              > > 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[/color][/color]
              reason[color=blue][color=green]
              > > why you couldn't just take these modules and put them in your own[/color][/color]
              private[color=blue][color=green]
              > > directory. There is nothing secret here.
              > >[/color]
              > I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?
              >[/color]

              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:
              [color=blue][color=green][color=darkred]
              >>> print MySQLdb.version _info[/color][/color][/color]
              (1, 2, 0, 'final', 1)

              There doesn't seem to be .c code to be found anywhere.
              Thomas Bartkus


              Comment

              • Steve Holden

                #8
                Re: Python and MySQL

                Thomas Bartkus wrote:[color=blue]
                > "Steve Holden" <steve@holdenwe b.com> wrote in message
                > news:mailman.44 .1130970219.187 01.python-list@python.org ...
                >[color=green]
                >>Thomas Bartkus wrote:
                >>[color=darkred]
                >>>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[/color][/color]
                >
                > reason
                >[color=green][color=darkred]
                >>>why you couldn't just take these modules and put them in your own[/color][/color]
                >
                > private
                >[color=green][color=darkred]
                >>>directory. There is nothing secret here.
                >>>[/color]
                >>
                >>I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?
                >>[/color]
                >
                >
                > 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:
                >
                >[color=green][color=darkred]
                >>>>print MySQLdb.version _info[/color][/color]
                >
                > (1, 2, 0, 'final', 1)
                >[/color]
                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/

                Comment

                • Aquarius

                  #9
                  Re: Python and MySQL

                  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

                  Comment

                  • Sion Arrowsmith

                    #10
                    Re: Python and MySQL

                    Aquarius <stefan.kanev@g mail.com> wrote:[color=blue]
                    >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
                    >functionalit y?[/color]

                    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 -- siona@chiark.gr eenend.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

                    Comment

                    • Thomas Bartkus

                      #11
                      Re: Python and MySQL

                      "Steve Holden" <steve@holdenwe b.com> wrote in message
                      news:mailman.49 .1130981382.187 01.python-list@python.org ...[color=blue]
                      > Thomas Bartkus wrote:[color=green]
                      > > "Steve Holden" <steve@holdenwe b.com> wrote in message
                      > > news:mailman.44 .1130970219.187 01.python-list@python.org ...
                      > >[color=darkred]
                      > >>I have a _mysql.c as a part of my distrbution of MySQLdb. Don't you?
                      > >>[/color]
                      > >
                      > >
                      > > 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:
                      > >
                      > >[color=darkred]
                      > >>>>print MySQLdb.version _info[/color]
                      > >
                      > > (1, 2, 0, 'final', 1)
                      > >[/color]
                      > 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?[/color]

                      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



                      Comment

                      • Gerhard Häring

                        #12
                        Re: Python and MySQL

                        Thomas Bartkus wrote:[color=blue]
                        > [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].[/color]

                        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

                        Comment

                        • Magnus Lycka

                          #13
                          Re: Python and MySQL

                          Thomas Bartkus wrote:[color=blue]
                          > 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].[/color]

                          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?
                          Download MySQL for Python for free. MySQL database connector for Python programming. MySQLdb is a Python DB API-2.0-compliant interface; see PEP-249 for details.


                          What's this doing in setup.py?
                          'ext_modules': [
                          Extension(
                          name='_mysql',
                          sources=['_mysql.c'],
                          include_dirs=in clude_dirs,
                          library_dirs=li brary_dirs,
                          libraries=libra ries,
                          extra_compile_a rgs=extra_compi le_args,
                          extra_objects=e xtra_objects,
                          ),
                          ],

                          Comment

                          • Thomas Bartkus

                            #14
                            Re: Python and MySQL

                            "Magnus Lycka" <lycka@carmen.s e> wrote in message
                            news:dkdbov$s2b $1@wake.carmen. se...[color=blue]
                            > Thomas Bartkus wrote:[color=green]
                            > > 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[/color][/color]
                            while[color=blue][color=green]
                            > > there are other file extensions, everything seems to have a[/color][/color]
                            corresponding[color=blue][color=green]
                            > > [.py].[/color]
                            >
                            > 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?[/color]

                            Yes!

                            And thank you so much for pointing that out :-)
                            Thomas Bartkus
                            [color=blue]
                            > 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=in clude_dirs,
                            > library_dirs=li brary_dirs,
                            > libraries=libra ries,
                            > extra_compile_a rgs=extra_compi le_args,
                            > extra_objects=e xtra_objects,
                            > ),
                            > ],[/color]


                            Comment

                            Working...