“MySQL Connection Python” Kode Jawaban

Hubungkan Python ke MySQL

import mysql.connector
mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword",
  port = 8888, #for Mamp users
  database='whatever db you want'
)
print(mydb) 
Alex29

Konektivitas Python dan MySQL

import pymysql

############### CONFIGURE THIS ###################
# Open database connection
db = pymysql.connect("database_host","username","password","database_name")
##################################################

# prepare a cursor object using cursor() method
cursor = db.cursor()

# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")

# Fetch a single row using fetchone() method.
data = cursor.fetchone()
print ("Database version : {0}".format(data))

# disconnect from server
db.close()
Razoltheren

Python terhubung ke mysql

import mysql.connector

# MySql Connection 
mydb = mysql.connector.connect(
  host="localhost",
  user="root",
  password="yourpassowrd",
  database="databasename"
)
Muthukumar

MySQL Connection Python

from sqlalchemy import types, create_engine
import pymysql

try:
	conn = create_engine('mysql+pymysql://user:pass@IP/database_name')
  	print("MySQL Connection Sucessfull!!!!!!!!!!!")

except Exception as err:

	print("MySQL Connection Failed !!!!!!!!!!!")
	print(err)
Sachin

Jawaban yang mirip dengan “MySQL Connection Python”

Pertanyaan yang mirip dengan “MySQL Connection Python”

Lebih banyak jawaban terkait untuk “MySQL Connection Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya