PythonのO/RマッパーでSQLを操作できるSQLAlchemyを紹介します。他のPythonライブラリとの連動もしやすいため非常に便利なライブラリです。 O/Rマッパーのメリット/デメリットの記事を参考に貼っておきます。 なおサンプルデータは下記を使用していきます。
前回の記事でPostgreSQLのサーバー立ち上げとテーブル作成までできたので、今回はPythonのプログラムからDB操作をします。 1.Pythonライブラリの準備 PythonからPostgreSQLの操作をするための準備をしていきます。 主にこちらの記事を参考にさせていただきました。
What are the main differences between sqlalchemy-ORM and slqalchemy-core? SQLAlchemy provides two main components for interacting with databases: SQLAlchemy ORM (Object-Relational Mapping) and ...
The server will be available at http://127.0.0.1:8000. database.py: This file's only job is to connect to the PostgreSQL database. It creates the SQLAlchemy engine, a ...
一部の結果でアクセス不可の可能性があるため、非表示になっています。
アクセス不可の結果を表示する