1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, DateTime, Boolean from sqlalchemy.orm import sessionmaker engine = create_engine( 'mysql://zhongming:zhongming@localhost/zhongming?charset=utf8' ) Base = declarative_base() Session = sessionmaker(bind = engine) class Mynews(Base): __tablename__ = 'table2' id = Column(Integer, primary_key = True ) type = Column(String( 10 ), nullable = False ) name = Column(String( 20 ), nullable = False ) author = Column(String( 20 ), nullable = False ) content = Column(String( 1000 ), nullable = False ) view_count = Column(Integer) public_time = Column(DateTime) is_valid = Column(Boolean) # Mynews.metadata.create_all(engine) |
D:\python36\lib\site-packages\sqlalchemy\engine\default.py:507: Warning: (1366, "Incorrect string value: '\\xD6\\xD0\\xB9\\xFA\\xB1\\xEA...' for column 'VARIABLE_VALUE' at row 497")
cursor.execute(statement, parameters)
一次实战同时掌握Python操作MySQL,MongoDB,Redis 三大数据库使用技巧
了解课程1.2k 13
1.2k 12
3.2k 12
1.7k 11
5.8k 10