import sqlalchemyfrom sqlalchemy.ext.declarative import declarative_basefrom sqlalchemy import column, integer, string, foreignkey, uniqueconstraint, index,datefrom sqlalchemy.orm import sessionmaker, relationshipfrom sqlalchemy Import create_engine,textimport datetime, pymysql,hashlib,getpass,refrom core import  SETTINGHASH = HASHLIB.MD5 () hash.update (' 123456 '. Encode ()) default_pw=hash.hexdigest () Mysql_user = setting.mysql_usermysql_pw = setting.mysql_pwmysql_host = setting.mysql_ Hostmysql_port = setting.mysql_port# conn = pymysql.connect (host= ' 192.168.153.132 ', Port=3306,user= ' root ', passwd= ' MySQL ', db= ' class ') Conn = pymysql.connect (host=mysql_host,port=mysql_ Port,user=mysql_user,passwd=mysql_pw,db= ' class ') Cursor = conn.cursor () # engine = Create_engine ("Mysql+pymysql://root: [Email protected]:3306/class ", encoding= ' Utf-8 ', echo=false) engine = create_engine (" mysql+ Pymysql://%s:%[email protected]%s:%s/class " % (mysql_user,mysql_pw,mysql_host,mysql_port), encoding= ' Utf-8 ', echo=false) base = declarative_base ()
SQLAlchemy and Pymysql ways to connect to MySQL