Job Search Engine
1702 浏览 5 years, 8 months
1.2.1 sqlalchemy
版权声明: 转载请注明出处 http://www.codingsoho.com/- sqlalchemy简单操作(创建表,反射表)
- Python数据库(三)-使用sqlalchemy创建表
- sqlalchemy(一)基本操作
- 使用SQLAlchemy
- MySQL第四天---多表操作(1对1、1对多、多对多)
- MySQL一对一:一对多:多对多: 实例!!!!
- MySQL主键和外键使用及说明
- Python+SQLAlchemy+MySQLdb+MySQL的中文乱码及其解决办法
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-2: ordinal not in range(256)
两种办法:
self.engine=create_engine("mysql://user:pass@localhost/test",connect_args={'charset':'utf8'}) workaround 1, take effect
self.engine=create_engine("mysql://user:pass@localhost/test?charset=utf8") #workaround 2, take effect
AttributeError: 'InstrumentedList' object has no attribute 'filter'
from sqlalchemy import Date, cast
from datetime import date
# job_entries_objs = record.job_entries.filter(cast(JobEntry.created,Date) == date.today()).all()
job_entries_objs = record.job_entries.filter(JobEntry.created > oneDayAgo ).all()
class JobEntry(Base):
__tablename__='job_entry'
id = Column(Integer, nullable=False, primary_key=True, autoincrement=True)
title = Column(String(200))
salary = Column(String(45))
region = Column(String(45))
degree = Column(String(45))
experience = Column(String(45))
company = Column(String(145))
industry = Column(String(145))
description = Column(Text(300))
href = Column(String(100))
# created = Column(DateTime, default=datetime.datetime.utcnow)
# updated = Column(DateTime, default=datetime.datetime.utcnow)
created = Column(DateTime, default=datetime.datetime.now)
updated = Column(DateTime, default=datetime.datetime.now)
trigger_scrap_records = relationship('TriggerScrapRecord',
secondary = job_entry_m2m_trigger_scrap_record,
# backref = 'job_entries',
backref=('job_entries', {'lazy':'dynamic'}),
# cascade="all, delete-orphan", # delete-orphan cascade is not supported on a many-to-many or many-to-one relationship when single_parent is not set.
lazy='dynamic',
passive_deletes=True)
def __repr__(self):
return self.title
- https://stackoverflow.com/questions/11578070/sqlalchemy-instrumentedlist-object-has-no-attribute-filter
- https://blog.csdn.net/weixin_40161254/article/details/82689372
- https://stackoverflow.com/questions/7075828/make-sqlalchemy-use-date-in-filter-using-postgresql