openstack组件的数据库操作

一、基础

SQLAlchemy

http://docs.sqlalchemy.org/en/rel_0_9/index.html

对数据库进行操作的工具:xxx-manage db ...

二、数据库表的创建和修改

使用SQLAlchemy-SQL Expression Language:

http://sqlalchemy.readthedocs.org/en/rel_0_9/core/tutorial.html

使用SQLAlchemy-Migrate

http://sqlalchemy-migrate.readthedocs.org/en/latest/

db/sqlalchemy:

migrate_repo:Migrate工具原生的repository

migration.py:实际是对migrate_repo里面的manage.py脚本功能的定制,用于数据库版本控制和版本获取

  

三、数据库表的使用

使用SQLAlchemy-ORM

http://sqlalchemy.readthedocs.org/en/rel_0_9/orm/tutorial.html

db/sqlalchemy:

models.py:映射到数据库表的模型定义

api.py:通过对模型的操作来对数据库表中的数据进行CRUD操作(注意不是对表本身进行变动)

参考文档:

http://docs.openstack.org/developer/oslo.db/

原文地址:https://www.cnblogs.com/littlebugfish/p/4162952.html