|
|
@ -6,7 +6,7 @@ import logging
|
|
|
|
import MySQLdb
|
|
|
|
import MySQLdb
|
|
|
|
from models.quotes import Quotes
|
|
|
|
from models.quotes import Quotes
|
|
|
|
from settings.config import MYSQL_CONFIG, SQLACHEMY
|
|
|
|
from settings.config import MYSQL_CONFIG, SQLACHEMY
|
|
|
|
from sqlalchemy import func
|
|
|
|
from sqlalchemy.sql import func
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
@ -89,8 +89,8 @@ def get_quotes(ids: list) -> tuple:
|
|
|
|
ids: List of quote ID's
|
|
|
|
ids: List of quote ID's
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
with Session(SQLACHEMY) as session:
|
|
|
|
with Session(SQLACHEMY) as session:
|
|
|
|
response = session.query(Quotes).filter(Quotes.id.not_in(ids))
|
|
|
|
response = session.query(Quotes).filter(Quotes.id.not_in(ids)).order_by(func.random()).first()
|
|
|
|
return [item for item in response]
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_by_id(id: int) -> object:
|
|
|
|
def get_by_id(id: int) -> object:
|
|
|
|