(c) 2016 Microsoft Corporation. All rights reserved.
C:\Users\Deepak>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> db = MySQLdb.connect(host = "localhost", user="root" passwd="root" db="world")
File "<stdin>", line 1
db = MySQLdb.connect(host = "localhost", user="root" passwd="root" db="world")
^
SyntaxError: invalid syntax
>>> db = MySQLdb.connect(host = "localhost", user="root", passwd="root", db="world")
>>> cur = db.cursor()
>>> cur.execute("select count(*) from city")
1L
>>> for row in cur.fetchall():
... print row[0]
...
4079
>>> db.close()
>>>
C:\Users\Deepak>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> db = MySQLdb.connect(host = "localhost", user="root" passwd="root" db="world")
File "<stdin>", line 1
db = MySQLdb.connect(host = "localhost", user="root" passwd="root" db="world")
^
SyntaxError: invalid syntax
>>> db = MySQLdb.connect(host = "localhost", user="root", passwd="root", db="world")
>>> cur = db.cursor()
>>> cur.execute("select count(*) from city")
1L
>>> for row in cur.fetchall():
... print row[0]
...
4079
>>> db.close()
>>>
No comments:
Post a Comment