Advertisement
mon0l1t

bot discord

Jul 4th, 2020
1,536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.05 KB | None | 0 0
  1. from sqlalchemy import create_engine
  2. from sqlalchemy.ext.declarative import declarative_base
  3. from sqlalchemy import Column, Integer, String
  4. from sqlalchemy.orm import sessionmaker
  5.  
  6.  
  7. Base = declarative_base()
  8. engine = create_engine('postgresql+psycopg2://neko:wakanim@localhost/nekoland')
  9. Session = sessionmaker(bind=engine)
  10. session = Session()
  11.  
  12.  
  13. class Guild(Base):
  14.     __tablename__ = 'guild_info'
  15.  
  16.     id = Column(Integer, primary_key=True)
  17.     name = Column(String)
  18.     description = Column(String)
  19.     image = Column(String)
  20.     color = Column(String)
  21.     lvl = Column(Integer)
  22.     local_rating = Column(Integer)
  23.     global_rating = Column(Integer)
  24.     text_channel = Column(Integer)
  25.     voice_channel = Column(Integer)
  26.     balance = Column(Integer)
  27.     tax = Column(Integer)
  28.     is_private = Column(Boolean, default=True)
  29.     users = relationship("Guild_users", backfer='guild_info')
  30.  
  31.     def __init__(self, name, description, image, color, lvl, local_rating, global_rating, text_channel, voice_channel, balance, tax, is_private):
  32.         self.name = name
  33.         self.description = description
  34.         self.image = image
  35.         self.color = color
  36.         self.lvl = lvl
  37.         self.local_rating = local_rating
  38.         self.global_rating = global_rating
  39.         self.text_channel = text_channel
  40.         self.voice_channel = voice_channel
  41.         self.balance = balance
  42.         self.tax = tax
  43.         self.is_private = is_private
  44.  
  45.     def __repr__(self):
  46.         return "<Guild('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')>" % (self.name, self.description, self.image, self.color, self.lvl, self.local_rating, self.global_rating, self.text_channel, self.voice_channel, self.balance, self.tax, self.is_private)
  47.  
  48.  
  49. class Guild_rank(Base):
  50.     __tablename__ = 'guild_rank'
  51.  
  52.     id = Column(Integer, primary_key=True)
  53.     name = Column(String)
  54.     description = Column(String)
  55.     users = relationship("Guild_users", backfer='guild_rank')
  56.  
  57.     def __init__(self, name, description):
  58.         self.name = name
  59.         self.description = description
  60.  
  61.     def __repr__(self):
  62.         return "<Guild_rank('%s', '%s')>" % (self.name, self.description)
  63.  
  64.  
  65. class Guild_users(Base):
  66.     __tablename__ = 'guild_users'
  67.  
  68.     id = Column(Integer, primary_key=True)
  69.     user_id = Column(Integer)
  70.     guild_id = Column(Integer,ForeignKey('guild_info.id'))
  71.     rank = Column(Integer,ForeignKey('guild_rank.id'))
  72.  
  73.  
  74.     def __init__(self, name, is_used, guild_id, rank):
  75.         self.user_id = user_id
  76.         self.guild_id = guild_id
  77.         self.rank = rank
  78.  
  79.     def __repr__(self):
  80.         return "<Guild_users('%s', '%s', '%s')>" % (self.user_id, self.guild_id, self.rank)
  81.  
  82.  
  83. class Category_commands(Base):
  84.     __tablename__ = 'category_commands'
  85.  
  86.     id = Column(Integer, primary_key=True)
  87.     name = Column(String)
  88.     description = Column(String)
  89.     commands = relationship("Commands", backfer='category_commands')
  90.  
  91.     def __init__(self, name, description):
  92.         self.name = name
  93.         self.description = description
  94.  
  95.     def __repr__(self):
  96.         return "<Category_commands('%s', '%s')>" % (self.name, self.description)
  97.  
  98.  
  99. class Commands(Base):
  100.     __tablename__ = 'commands'
  101.  
  102.     id = Column(Integer, primary_key=True)
  103.     name = Column(String)
  104.     description = Column(String)
  105.     category = Column(Integer,ForeignKey('category_commands.id'))
  106.  
  107.     def __init__(self, name, description, category):
  108.         self.name = name
  109.         self.description = description
  110.         self.category = category
  111.  
  112.     def __repr__(self):
  113.         return "<Commands('%s', '%s', '%s')>" % (self.name, self.description, self.category)
  114.  
  115.  
  116. class Guild_settings(Base):
  117.     __tablename__ = 'guild_settings'
  118.  
  119.     id = Column(Integer, primary_key=True)
  120.     name = Column(String)
  121.     coefficient = Column(Double)
  122.  
  123.     def __init__(self, name, coefficient):
  124.         self.name = name
  125.         self.coefficient = coefficient
  126.  
  127.     def __repr__(self):
  128.         return "<guild_settings('%s', '%s')>" % (self.name, self.coefficient)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement