Using python with MySQL

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

    #1

    Using python with MySQL


    Greetings,

    I need to peform some simple queries via MySQL. Searching the list I
    see that folks are accessing it with python. I am very new to python
    and pretty new to MySQL too. Would appreciate it if you could point me
    to some documentation for accessing MySQL via python. Something of the
    "Python and MySQL for Dummies" caliber would be about my speed, but of
    course I will be thankful for anything offered.

    Thanks,

    jvh

  • Greg Donald

    #2
    Re: Using python with MySQL

    On 1 May 2007 12:40:20 -0700, HMS Surprise <john@datavoice int.comwrote:
    I need to peform some simple queries via MySQL. Searching the list I
    see that folks are accessing it with python. I am very new to python
    and pretty new to MySQL too. Would appreciate it if you could point me
    to some documentation for accessing MySQL via python. Something of the
    "Python and MySQL for Dummies" caliber would be about my speed, but of
    course I will be thankful for anything offered.





    --
    Greg Donald

    Comment

    • Shafik

      #3
      Re: Using python with MySQL

      On May 1, 10:40 pm, HMS Surprise <j...@datavoice int.comwrote:
      Greetings,
      >
      I need to peform some simple queries via MySQL. Searching the list I
      see that folks are accessing it with python. I am very new to python
      and pretty new to MySQL too. Would appreciate it if you could point me
      to some documentation for accessing MySQL via python. Something of the
      "Python and MySQL for Dummies" caliber would be about my speed, but of
      course I will be thankful for anything offered.
      >
      Thanks,
      >
      jvh
      hi,
      download this module:
      http://sourceforge.net/projects/mysql-python
      and look at the tutorial here:


      Comment

      • HMS Surprise

        #4
        Re: Using python with MySQL

        On May 1, 2:58 pm, "Greg Donald" <gdon...@gmail. comwrote:
        On 1 May 2007 12:40:20 -0700, HMS Surprise <j...@datavoice int.comwrote:
        >
        I need to peform some simple queries via MySQL. Searching the list I
        see that folks are accessing it with python. I am very new to python
        and pretty new to MySQL too. Would appreciate it if you could point me
        to some documentation for accessing MySQL via python. Something of the
        "Python and MySQL for Dummies" caliber would be about my speed, but of
        course I will be thankful for anything offered.
        >

        >
        --
        Greg Donaldhttp://destiney.com/

        Most excellent!

        Many thanks, Greg. I'll get started reading pronto.


        jvh

        Comment

        • HMS Surprise

          #5
          Re: Using python with MySQL

          Done, thank you too.

          jh

          Comment

          • hlubenow

            #6
            Re: Using python with MySQL

            HMS Surprise wrote:
            Greetings,
            >
            I need to peform some simple queries via MySQL. Searching the list I
            see that folks are accessing it with python. I am very new to python
            and pretty new to MySQL too. Would appreciate it if you could point me
            to some documentation for accessing MySQL via python. Something of the
            "Python and MySQL for Dummies" caliber would be about my speed, but of
            course I will be thankful for anything offered.
            >
            Thanks,
            >
            jvh
            There's even another approach:
            If you're on Linux, Qt3 may be available. Install its Python-bindings. Given
            a database "MyDatabase ", with password "MyPassword " for user "root" and
            inside the database a table "MyTable", you can then do something like this:

            ----------------------------------------------------
            #!/usr/bin/env python

            from qt import *
            import sys
            from qtsql import QSqlDatabase, QSqlQuery

            app = QApplication(sy s.argv)

            DB = QSqlDatabase("Q MYSQL3", "MyDatabase ", app)

            DB.setDatabaseN ame("MyDatabase ")
            DB.setUserName( "root")
            DB.setPassword( "MyPassword ")
            DB.setHostName( "localhost" )
            DB.open()

            c = DB.execStatemen t("select * from MyTable")

            while c.next():
            print c.value(0).toSt ring()
            print c.value(1).toSt ring()
            print c.value(2).toSt ring()
            print c.value(3).toSt ring()
            c.first()

            c2 = DB.execStatemen t("select count(*) from MyTable")
            c2.next()

            print c2.value(0).toS tring()
            ----------------------------------------------------

            Some further documentation:

            Find information, resources and relevant links for trolltech.com. This domain may be for sale.


            H.

            Comment

            • hlubenow

              #7
              Re: Using python with MySQL

              hlubenow wrote:
              There's even another approach: ...
              On the other hand you may be better off with the "mysql-python"-module.

              Anyway, here's a nice overview over the most commonly used MySQL-commands
              (The commands should speak for themselves, even if the explanations are in
              German):



              H.


              Comment

              Working...