Initial switch to gino for discordbot db

This commit is contained in:
Jeremy Zhang
2018-07-10 07:04:19 +00:00
parent 3ca6a33be7
commit ac225c84f5
8 changed files with 153 additions and 311 deletions

View File

@ -1,6 +1,6 @@
from titanembeds.database import db, Base
from titanembeds.database import db
class Messages(Base):
class Messages(db.Model):
__tablename__ = "messages"
message_id = db.Column(db.BigInteger, primary_key=True) # Message snowflake
guild_id = db.Column(db.BigInteger) # Discord guild id
@ -11,19 +11,4 @@ class Messages(Base):
edited_timestamp = db.Column(db.TIMESTAMP) # Timestamp of when content is edited
mentions = db.Column(db.Text()) # Mentions serialized
attachments = db.Column(db.Text()) # serialized attachments
embeds = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql')) # message embeds
def __init__(self, guild_id, channel_id, message_id, content, author, timestamp, edited_timestamp, mentions, attachments, embeds):
self.guild_id = guild_id
self.channel_id = channel_id
self.message_id = message_id
self.content = content
self.author = author
self.timestamp = timestamp
self.edited_timestamp = edited_timestamp
self.mentions = mentions
self.attachments = attachments
self.embeds = embeds
def __repr__(self):
return '<Messages {0} {1} {2} {3} {4}>'.format(self.id, self.guild_id, self.guild_id, self.channel_id, self.message_id)
embeds = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql')) # message embeds