Python + MySQL in playlist: http://www.youtube.com/watch?v=lhU2OZCKXhQ&feature=share&list=PLQVvvaa0QuDfhTF3Zfyzc_yD-Mq9iTp4G&index=26 This …
Original source
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”
If anyone is following in 2018, Pythonanywhere has changed the host from "mysql.server" to "username.mysql.pythonanywhere-services.com"
if anyone is getting this error -> _mysql_exceptions.OperationalError: (2005, "Unknown MySQL server host 'mysql.server' (0)")
You have to change the host name.
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'
Thank you so much for this tutorial! I was stuck and beginning to lose hope.
can i use MySQLdb in python3.6. Even pip can´t find this library
where tf is the insert????
Where's the INSERT?
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
how to install the mysqldb module
I am NOT using python anywhere , I am using Anaconda(Spyder)
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.
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?
free accounts can have 2 consoles, just fyi.
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
The ImportError: No module named MySQLdb is easily solved.
Open a bash console and type in:
pip3.4 install –user https://github.com/davispuh/MySQL-for-Python-3/archive/1.0.tar.gz
pip3.3 for python 3.3 🙂
pythonanywhere.com/wiki/UsingMySQL for more guidelines.
+ChangeTip pez
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