Reputation: 13
I'm new in this python and mysql. I attempt to view the first row of data from my database. This is my code:
import MySQLdb
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", # your username
passwd="", # your passwords
db="58c_t2d_10") # name of the database
# you must create a Cursor object.
# It will let you execute all the queries you need
cur = db.cursor()
# Use all the SQL you like
cur.execute("SELECT * 58c_10")
# print all the first cell of all the rows
for row in cur.fetchall() :
print row[0]
And I got this error:
OperationalError: (1044, "Access denied for user ''@'localhost'
to database '58c_t2d_10'")
I've tried to sign in as root:
ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the
right syntax to use near '58c_10' at line 1")
Upvotes: 0
Views: 34