共计 681 个字符,预计需要花费 2 分钟才能阅读完成。
1.python 连接 mysql8.0 数据库
import pandas as pd
from sqlalchemy import create_engine
engine = create_engine('mysql+mysqlconnector://root:123456@localhost:3306/ssm')
sql = 'select * from teacher;'
df = pd.read_sql_query(sql,engine)
print(df)
2.R 连接 mysql8.0 数据库 (自行配置 ODBC)
library(RODBC)
channel <- odbcConnect("RMySQL",uid = "root",pwd = "123456")
crimedat <- sqlQuery(channel,"select * from teacher")
print(crimedat)
3.python 连接 mongodb4.2 数据库 (本人 mongo 没设密码)
from pymongo import MongoClient
connect = MongoClient('mongodb://localhost:27017/')
db = connect['analysis']
collection = db['student']
collection.find_one()
4.R 连接 mongodb4.2 数据库 (本人 mongo 没设密码)
library(mongolite)
con <- mongo(collection = "student",db = "analysis", url = "mongodb://localhost")
con$find()
正文完