WHY AM I GETTING THIS ERROR? What is the solution? with conn: AttributeError: __name__ Code Below: import serial import time import MySQLdb as mdb arduino = serial.Serial('/dev/ttyACM0') arduino.baudrate=9600 data = arduino.readline() time.sleep(1) data = arduino.readline() pieces = data.decode('utf-8').split("\t") # pieces = data.decode('utf-8').rstrip() temperature = pieces humidity = pieces conn = mdb.connect('localhost','root','raspberry','exampledb'); cursor = conn.cursor() with conn: cursor.execute("""INSERT INTO tempDB (Temperature,humidity) VALUES(1,%s,%s)""",(te
WHY AM I GETTING THIS ERROR? What is the solution? with conn: AttributeError: __name__ Code Below: import serial import time import MySQLdb as mdb arduino = serial.Serial('/dev/ttyACM0') arduino.baudrate=9600 data = arduino.readline() time.sleep(1) data = arduino.readline() pieces = data.decode('utf-8').split("\t") # pieces = data.decode('utf-8').rstrip() temperature = pieces humidity = pieces conn = mdb.connect('localhost','root','raspberry','exampledb'); cursor = conn.cursor() with conn: cursor.execute("""INSERT INTO tempDB (Temperature,humidity) VALUES(1,%s,%s)""",(te
Chapter7: Working With The Bash Shell
Section: Chapter Questions
Problem 7DE
Related questions
Question
WHY AM I GETTING THIS ERROR? What is the solution?
with conn:
AttributeError: __name__
Code Below:
import serial
import time
import MySQLdb as mdb
arduino = serial.Serial('/dev/ttyACM0')
arduino.baudrate=9600
data = arduino.readline()
time.sleep(1)
data = arduino.readline()
pieces = data.decode('utf-8').split("\t")
# pieces = data.decode('utf-8').rstrip()
temperature = pieces
humidity = pieces
conn = mdb.connect('localhost','root','raspberry','exampledb');
cursor = conn.cursor()
with conn:
cursor.execute("""INSERT INTO tempDB (Temperature,humidity) VALUES(1,%s,%s)""",(temperature,humidity))
conn.commit()
cursor.close()
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 5 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:
9781337569798
Author:
ECKERT
Publisher:
CENGAGE L
LINUX+ AND LPIC-1 GDE.TO LINUX CERTIF.
Computer Science
ISBN:
9781337569798
Author:
ECKERT
Publisher:
CENGAGE L