Python में Databases का परिचय
Jason Myers
Co-Author of Essential SQLAlchemy and Software Engineer
create_engine() स्टेटमेंट उन्हें बना देगाfrom sqlalchemy import (Table, Column, String, Integer, Decimal, Boolean)employees = Table('employees', metadata, Column('id', Integer()), Column('name', String(255)), Column('salary', Decimal()), Column('active', Boolean()))metadata.create_all(engine)engine.table_names()
[u'employees']
autoload कीवर्ड आर्ग्युमेंट्स को Column ऑब्जेक्ट्स से बदला जाता हैcreate_all() से असली डेटाबेस में टेबल बनती हैंunique किसी कॉलम के सभी मानों को यूनिक रहने को बाध्य करता हैnullable तय करता है कि किसी पंक्ति में कॉलम खाली हो सकता है या नहींdefault तब डिफॉल्ट मान सेट करता है जब कोई मान न दिया जाए।employees = Table('employees', metadata, Column('id', Integer()), Column('name', String(255), unique=True, nullable=False), Column('salary', Float(), default=100.00), Column('active', Boolean(), default=True))employees.constraints
{CheckConstraint(...
Column('name', String(length=255), table=<employees>, nullable=False),
Column('salary', Float(), table=<employees>,
default=ColumnDefault(100.0)),
Column('active', Boolean(), table=<employees>,
default=ColumnDefault(True)), ...
UniqueConstraint(Column('name', String(length=255),
table=<employees>, nullable=False))}
Python में Databases का परिचय