https://www.python.org/
Double-click on Install Certificates command
baca readme.
cek versi di terminal
python3 --version
#taraaa!!!!
instal VS Code
buat file .py ketik
print('Hello');
run
#tarararaa!!!!
cara konek ke mysql
install mysql conector
pip3 install mysql-connector-python
buat file config_mysql.py
ketikan
import mysql.connector
cnx = mysql.connector.connect(user='root', password='tsp123',
host='127.0.0.1',port='3314',
database='8_agustus_2023')
if cnx.is_connected():
print("Berhasil terhubung ke database")
cursor = cnx.cursor()
sql = "SELECT * FROM company"
# pastikan table company ada ya
cursor.execute(sql)
results = cursor.fetchall()
for data in results:
print(data)
cnx.close()
if cnx.is_connected():
print("Masih terkoneksi")
else :
print("koneksi sudah ditutup")
Tidak ada komentar:
Posting Komentar