SQLAlchemy is an open source SQL toolkit and ORM framework for the Python programming language to the Object - relational impedance mismatch to skirt around as well as Java Hibernate. SQLAlchemy was published in February 2006.
SQLAlchemy provides a set of design patterns for efficient Persistenzhaltung of data in a relational database. The motivation behind SQLAlchemy is due to the fact that SQL databases are similar to less object collections, the more extensive the data set and the more power is in demand, while collections of objects less like relations and tuples behave the more abstracted between data representation and mini world. Therefore SQLAlchemy primarily follows a Data Mapper pattern instead of a so-called " Active Record " pattern. Optional plugins allow more patterns, eg Elixir with a declarative syntax.
Generating an M: N relationship (Authorship) between the book and the author (without imports ):
Base = declarative_base () engine = sqlalchemy.create_engine ( ' postgres :/ / user: pwd @ host / dbname ', echo = True) authorship = Table ( ' buch_autor ', Base.metadata, Column ( ' isbn ', Integer, ForeignKey ( ' buch.isbn ')), Column ( ' identifier ', Integer, ForeignKey ( ' autor.kennung ')) ) class Book ( Base ): __tablename__ = ' book ' isbn = Column ( Integer, primary_key = True) title = Column ( String (255 ), nullable = False) blurb = Column (Text ) authors = relationship (Author, secondary = authorship backref, = ' buffet ') class Author ( Base ): __tablename__ = ' author ' identifier = Column (String (32 ), primary_key = True) name = Column (String (50 ), nullable = False, unique = True) Base.metadata.create_all (engine) Supported databases
SQLAlchemy supports a variety of database management systems:
- Informix IDS
- SAP MaxDB
- Microsoft Access
- Microsoft SQL Server
- Oracle Database