from sqlalchemy import create_engine, MetaData from sqlalchemy.orm import sessionmaker, declarative_base from databases import Database DATABASE_URL = 'postgresql://postgres:password@db:5432/db_name' engine = create_engine(DATABASE_URL) Session = sessionmaker(autocommit=False, autoflush=False, bind=engine) session = Session() Base = declarative_base() from sqlalchemy import ( Column, DateTime, Int
![PythonのORM、SQLAlchemyをまとめる(SELECT編)](https://cdn-ak-scissors.b.st-hatena.com/image/square/153fef3cc1ef9337ef0e07d831ba2bc579ed45a0/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fzenn%2Fimage%2Fupload%2Fs--QDeCq0if--%2Fco_rgb%3A222%252Cg_south_west%252Cl_text%3Anotosansjp-medium.otf_37_bold%3AMikio%252Cx_203%252Cy_98%2Fc_fit%252Cco_rgb%3A222%252Cg_north_west%252Cl_text%3Anotosansjp-medium.otf_70_bold%3APython%2525E3%252581%2525AEORM%2525E3%252580%252581SQLAlchemy%2525E3%252582%252592%2525E3%252581%2525BE%2525E3%252581%2525A8%2525E3%252582%252581%2525E3%252582%25258B%2525EF%2525BC%252588SELECT%2525E7%2525B7%2525A8%2525EF%2525BC%252589%252Cw_1010%252Cx_90%252Cy_100%2Fg_south_west%252Ch_90%252Cl_fetch%3AaHR0cHM6Ly9yZXMuY2xvdWRpbmFyeS5jb20vemVubi9pbWFnZS9mZXRjaC9zLS01RGw1ZklXUC0tL2NfbGltaXQlMkNmX2F1dG8lMkNmbF9wcm9ncmVzc2l2ZSUyQ3FfYXV0byUyQ3dfNzAvaHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL3plbm4tdXNlci11cGxvYWQvYXZhdGFyL2MzMTJkZTNmMjcuanBlZw%3D%3D%252Cr_max%252Cw_90%252Cx_87%252Cy_72%2Fv1627274783%2Fdefault%2Fog-base_z4sxah.png)