Exemplo n.º 1
0
 def __new__(cls, *args, **kwargs):
     if len(args) > 0:
         query = session.query(Keyword).filter_by(value = args[0]).first()
         if query != None:
             return query
         else:
             return Base.__new__(cls, *args, **kwargs)
Exemplo n.º 2
0
 def __new__(cls, *args, **kwargs):
     if len(args) > 0:
         query = session.query(Keyword).filter_by(value=args[0]).first()
         if query != None:
             return query
         else:
             return Base.__new__(cls, *args, **kwargs)
Exemplo n.º 3
0
  )
  iso_639_1 = Column(VARCHAR(50))
  iso_639_2 = Column(VARCHAR(50))
  iso_639_3 = Column(CHAR(4))

class PostalCodeModel(Base):
  __tablename__ = 'postal_codes'
  __table_args__ = (
    PrimaryKeyConstraint("country_code", "postal_code", "admin_code1", "admin_code2", "admin_code3"),
  )
  country_code = Column(CHAR(2))
  postal_code = Column(VARCHAR(20))
  admin_code1 = Column(VARCHAR(20))
  admin_code2 = Column(VARCHAR(20))
  admin_code3 = Column(VARCHAR(20))

class TimezoneModel(Base):
  __tablename__ = 'timezones'
  timezone_id = Column(Integer, primary_key=True, nullable=False)

class UserTagModel(Base):
  __tablename__ = 'usertags'
  __table_args__ = (
    PrimaryKeyConstraint("geoname_id", "tag"),
  )
  geoname_id = Column(Integer, ForeignKey("geoname.geoname_id"), nullable=False)
  tag = Column(VARCHAR(100))

Base.prepare(engine)

Exemplo n.º 4
0
 def ofId(self, _id: int, _type: Base):
     self._id = _id
     self._ins = Base.byId(_id)
     return self
Exemplo n.º 5
0
# Установленные модули
import re
import telebot
import logging.config

# Модули, созданные в ходе разработки.
import api_connection
from constants import ConstantsToken, ConstantsAnswers, Genres, LoggerConfig
from database import Base
from keyboard import *
from errors import FilmNotFound
from formatters import *

bot = telebot.TeleBot(ConstantsToken.TEST_API_TOKEN)
db = Base()

logging.config.dictConfig(LoggerConfig.dictLogConfig)
logger = logging.getLogger("console_logger")


@bot.message_handler(commands=["start"])
def show_start_message(message):
    bot.send_message(message.chat.id,
                     ConstantsAnswers.GREETING_MSG,
                     reply_markup=create_main_markup())


@bot.message_handler(
    content_types=["text"],
    func=lambda message: message.text == Commands.SEARCH_FILM_COMMAND)
def search_movie_command(message):
Exemplo n.º 6
0
            'manzana_geom_6362_json': func.ST_AsGeoJSON(
                func.ST_Transform(self.manzana_geom_6362)),
            'manzana_geom_4326_json': func.ST_AsGeoJSON(
                func.ST_Transform(self.manzana_geom_4326))
    }
        return data

## tabla dim_municipio
class DimMunicipio(Base):
    __tablename__ = "dim_municipio"
    __table_args__ = {'extend_existing': True}
    municipio_geom_6362 = Column(
        Geometry(geometry_type='MULTIPOLYGON',srid = 6362), nullable = True)
    municipio_geom_4326 = Column(
        Geometry(geometry_type='MULTIPOLYGON',srid = 4326), nullable = True)
    municipio_geom_6362_json = column_property(
        func.ST_AsGeoJSON(func.ST_Transform(municipio_geom_6362, 6362)))
    municipio_geom_4326_json = column_property(
        func.ST_AsGeoJSON(func.ST_Transform(municipio_geom_4326, 4326)))
    
    def to_dict(self):
        data = {
            'municipio_geom_6362_json': func.ST_AsGeoJSON(
                func.ST_Transform(self.municipio_geom_6362)),
            'municipio_geom_4326_json': func.ST_AsGeoJSON(
                func.ST_Transform(self.municipio_geom_4326))
    }
        return data

Base.prepare(engine, reflect = True)