Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import mysql.connector
- mydb = mysql.connector.connect(
- user='root',
- host='localhost',
- password='***')
- mycursor = mydb.cursor()
- mycursor.execute("select calldate, clid, src, dst from cdr.cdr
- where calldate like '2019-02-18%'
- ORDER BY calldate desc limit 2")
- myresult = mycursor.fetchall()
- for row in myresult:
- for fild in row:
- print (fild[0])
- print (fild[1])
- print (fild[2])
- print (fild[3])
- mydb.close()
- # python3.6 dumpMysql.py
- Traceback (most recent call last):
- File "dumpMysql.py", line 18, in <module>
- print (fild[0])
- TypeError: 'datetime.datetime' object is not subscriptable
- Primeira linha do select
- campo0
- campo1
- campo2
- campo3
- Segunda linha do select
- campo0
- campo1
- campo2
- campo3
Add Comment
Please, Sign In to add comment