2 odpowiedzi
+ 4
You have to install mysql.connector for that and then import the package as "import mysql. Connector as sq" on your python IDLE. Then open a connection to the database as "cob=sq.connect (host=host name, user=username,password =password of mysql,charset= utf-8)"
Then create a cursor instance as "cur=cob.cursor()" after which you have to execute the query as "cur.execute(<SQL query string you want to run>)".
Then, you can extract the data from mysql table using fetchall() method.
Note: All these steps must be executed in python idle....
Good luck bro...
+ 1
sqlite3 is a lightweight database engine and it is built into standard python (no external library needed to use it).
For more advanced integration, you can look at sqlalchemy ORM (object relational mapper) that provodes an abstraction over various types of databases.
https://www.sqlalchemy.org/
https://code.sololearn.com/csZ5bjiWfdCR/?ref=app