<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Using MySQLdb
mySQLdb - Library has to be pip'ed'  before and now to be imported
Step1:  Database Connection Properties and Connect to the database
Step12:  Let's create a sample table and insert some data into it.
Step14:  conn.cursor will return a cursor object, you can use this cursor to perform queries.
Step15:  Now you can print out the result set using pretty print
Step16:  Am Ende schließen wir die Verbindung
Step17:  Using ext sql
'from
<ASSISTANT_TASK:>
Python Code:
import MySQLdb
Explanation: Using MySQLdb
mySQLdb - Library has to be pip'ed'  before and now to be imported
End of explanation
#Enter the values for you database connection
dsn_database = "verein"   # e.g. "MySQLdbtest"
dsn_hostname = "localhost"       # e.g.: "mydbinstance.xyz.us-east-1.rds.amazonaws.com"
dsn_port = 3306                        # e.g. 3306 
dsn_uid = "steinam"             # e.g. "user1"
dsn_pwd = "steinam"            # e.g. "Password123"
conn = MySQLdb.connect(host=dsn_hostname, port=dsn_port, user=dsn_uid, passwd=dsn_pwd, db=dsn_database)
Explanation: Database Connection Properties and Connect to the database
End of explanation
conn.query(DROP TABLE IF EXISTS Cars)
conn.query(CREATE TABLE Cars(Id INTEGER PRIMARY KEY, Name VARCHAR(20), Price INT))
conn.query(INSERT INTO Cars VALUES(1,'Audi',52642))
conn.query(INSERT INTO Cars VALUES(2,'Mercedes',57127))
conn.query(INSERT INTO Cars VALUES(3,'Skoda',9000))
conn.query(INSERT INTO Cars VALUES(4,'Volvo',29000))
conn.query(INSERT INTO Cars VALUES(5,'Bentley',350000))
conn.query(INSERT INTO Cars VALUES(6,'Citroen',21000))
conn.query(INSERT INTO Cars VALUES(7,'Hummer',41400))
conn.query(INSERT INTO Cars VALUES(8,'Volkswagen',21600))
Explanation: Let's create a sample table and insert some data into it.
End of explanation
cursor=conn.cursor()
cursor.execute(SELECT * FROM Cars)
cursor.fetchone()
Explanation: conn.cursor will return a cursor object, you can use this cursor to perform queries.
End of explanation
print("\nShow me the records:\n")
rows = cursor.fetchall()
import pprint
pprint.pprint(rows)
Explanation: Now you can print out the result set using pretty print:
You should see the following results:
End of explanation
conn.close()
Explanation: Am Ende schließen wir die Verbindung
End of explanation
%load_ext sql
%sql mysql://steinam:steinam@localhost/verein
%sql select * from spieler;
result = _
print(result[3])
%sql describe strafen;
result = %sql SELECT Betrag, spielernr from strafen
 %matplotlib inline
result.bar()
Explanation: Using ext sql
'from: https://github.com/catherinedevlin/ipython-sql
pip install ipython-sql has to be done
End of explanation
<END_TASK>