Python MySQL
- Nakaraang Pahina Decision Tree
- Susunod Na Pahina MySQL Buhat Database
Python can be used in database applications.
MySQL is one of the most popular databases.
MySQL Database
To be able to test the code examples in this tutorial, you should install MySQL on your computer.
Download the free MySQL database here:https://www.mysql.com/downloads/.
Install MySQL Driver
Python requires the MySQL driver to access the MySQL database.
In this tutorial, we will use the driver "MySQL Connector".
We recommend you install "MySQL Connector" using PIP.
PIP is likely already installed in the Python environment.
Navigate to the command line location of PIP and then type the following:
Download and install "MySQL Connector":
C:\...\AppData\Local\Programs\Python\Python36-32\Scripts>python -m pip install mysql-connector
Ngayon, ka ay nakadownload at nag-install ng MySQL driver.
Test MySQL Connector
Kung gusto mong testin kung matagumpay ang pag-install o kung mayroon ka na ang "MySQL Connector", lumikha ka ng isang Python page na naglalaman ng sumusunod:
demo_mysql_test.py:
import mysql.connector
Kung walang maling nangyari sa pagpapatupad ng mga ito, ang "MySQL Connector" ay na-install at handa para sa paggamit.
Lumikha Ng Koneksyon
Una, lumikha ka ng koneksyon sa database.
Gamitin ang username at password ng MySQL database:
demo_mysql_connection.py:
import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", passwd="yourpassword" ) print(mydb)
Ngayon, maaari ka na ng magsimula sa paggamit ng SQL statement para sa pagtatanong ng database.
- Nakaraang Pahina Decision Tree
- Susunod Na Pahina MySQL Buhat Database