Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Sep 5th, 2010 | Syntax: Python | Size: 1.10 KB | Hits: 20 | Expires: Never
Copy text to clipboard
  1. #1 create database engine
  2.  
  3. from sqlalchemy import Column, Integer, String
  4. from arabtabs.db import Base
  5.  
  6. class User(Base):
  7.     __tablename__ = 'users'
  8.     id = Column(Integer, primary_key=True)
  9.     alias = Column(String(50), unique=True, nullable = False)
  10.     email = Column(String(120), unique=True, nullable = False)
  11.     pwd = email = Column(String(120), unique=True, nullable = False)
  12.     tabs = relationship("tabs", backref="user")
  13.  
  14.      
  15. class Tab(base):
  16.   __tablename__ = 'tabs'
  17.   id = Column(Integer, primary_key=True)
  18.   text = Column(Text, unique=True, nullable=False)
  19.   user_id = Column(Integer, ForeignKey('users.id'))
  20.   song_id = Column(Integer, ForeignKey('songs.id'))
  21.  
  22.  
  23. class Song(base):
  24.   __tablename__ = 'tabs'
  25.   id = Column(Integer, primary_key=True)
  26.   title = Column(Text, unique=True, nullable=False)
  27.   artist_id = Column(Integer, ForeignKey('artists.id'))
  28.    
  29.                    
  30.  class Artist(base):
  31.   __tablename__ = 'tabs'
  32.   id = Column(Integer, primary_key=True)
  33.   name = Column(Text, unique=True, nullable=False)
  34.   songs = relationship("artists", backref="artist")