MySQL Database with Python Tutorial Part 4 – Inserting Variables as Data




Python + MySQL in playlist: http://www.youtube.com/watch?v=lhU2OZCKXhQ&feature=share&list=PLQVvvaa0QuDfhTF3Zfyzc_yD-Mq9iTp4G&index=26 This …

Original source


15 responses to “MySQL Database with Python Tutorial Part 4 – Inserting Variables as Data”

  1. Connecting to 'mysql.server' didn't work for me. But 'username.mysql.pythonanywhere-services.com' worked. So in sentex's case that would be 'beginneraccount.mysql.pythonanywhere-services.com'

  2. can i ask some question please?
    1. i have some python program on my pc and mysql database at pythonanywhere, is there any way to access the data from my table via local pc script?
    2. how to get my data via local python script? lets just say i need to execute (select * from my_database) . how to execute it?
    3. is there any way to use json in pythonanywhere for mysql??

    thank you very much

  3. I am newbie in python and I am facing difficulty in storing
    various fields of html page into database.
    E.g, I have a html page which contains 5 fields and one submit button .
    On submitting the form, I want all values from html form should be
    stored in table of the given database.
    Please help me in this.

  4. Hello Sentdex,

    Sorry for giving you many questions here and there, but I have to figure this out.

    So I have a linux server I rent from Digital Ocean and I have set up everything followed by your tutorials. Now, in my windows 10 laptop computer, I want to connect to the linux server to access the mysql databases in that sever. For that, I first, in the linux server, granted my local windows computer ALL permissions with the ip address that I am connected to right now. And in python, I wrote
    conn = MySQLdb.connect("xxx.xxx.xxx.x", "new_username", "new_password", "database name" )
    But this does not work. I tried "new_username$database name" also. Not working. It give me this error message:
    OperationalError: (2003, "Can't connect to MySQL server on 'xxx.xxx.xxx.x' (10061)")

    What went wrong?

  5. Was not able to do it your way but after trial an error I managed:

    #!/usr/bin/env python2.7 (Seemst new default to 3 is making the problem as well)
    import MySQLdb

    db = MySQLdb.connect(host = 'xx', user = 'xx, passwd = 'xx', db = 'xx$default')

    c = db.cursor()

    c.execute("SELECT * FROM taula")

    rows = c.fetchall()

    for e in rows:
    print e

  6. If anyone is trying to do this on an RPI and is having troubles, and is having the "ImportError: No module named MySQLdb" …. i had troubles too until i removed python-mysqldb then reinstalled with aptitude
    "sudo aptitude install python-mysqldb"

    Thanks for your video's… they helped me alot

Leave a Reply