concept ( It's normal that people don't understand ):
SQLalchemy yes Python A framework for , yes Python A framework for operating a database , Operation for developers SQL Provides powerful functionality and flexibility ORM: Object
Relational Mapper --> Relational object mapping , Django I'll talk about it in detail .
declarative_base Class maintains a relationship from class to table , Usually an application uses one base example , All entity classes should inherit such objects
Link format of database :' Database type + Database driver name :// user name : Password @ Machine address : Port number / Database name ?charset=utf8' The premise of running the code :
Must enter in advance mysql + The database must be created in advance ( Data tables are generated with code , You don't have to create a data table ) Column: Meaning of column

from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String, Integer, Enum, ForeignKey, Date,

<> Create the base class of the object

Base = declarative_base()

<> Linked database

engine = create_engine(
“mysql+pymysql://mysql:qwe123@localhost/Python_12?charset=utf8”, echo=True,
pool_size=5, max_overflow=5

<> Department table

class Depart(Base):
tablename = “depart”
id = Column(Integer, primary_key=True, autoincrement=True, doc=' number ') name =
Column(String(20), unique=True, doc=' name ') def __init__(self, id, name): self.id
= id self.name = name
<> Employee table

class User(Base):
tablename = ‘user’
id = Column(Integer, primary_key=True, autoincrement=True, doc=' number ') name =
Column(String(20), doc=' name ') age = Column(Integer, doc=' Age ') gender =
Column(Enum(' male ', ' female '), default=' male ', doc=' Gender ') phone = Column(String(11),
doc=' Telephone ') depart_id = Column(Integer, ForeignKey('depart.id'), doc=' Binding Department id')
def __init__(self, id, name, age, gender, phone, depart_id): self.id = id
self.name = name self.age = age self.gender = gender self.phone = phone self.
depart_id = depart_id
if name == ‘main’:

©2019-2020 Toolsou All rights reserved,
【Java8 New features 1】Lambda Expression summary What is a process , Concept of process ?hdfs dfs Common basic commands java When creating objects, you must _Java Basic test questions Generation of random numbers + Figure guessing game When will we enter the old generation ?HDFS Common commands ( summary ) It is never recommended to spend a lot of time studying for employment pythonmacOS Big Sur The installation could not be completed Big Sur Why can't I install it ?Python pyttsx3| Text reading ( Various languages )