ÈÖ¹ßü

WHOOSH È®Àå SQLALCHEMY
Áö±Ý ´Ù¿î·Îµå

ÈÖ¹ßü ¼øÀ§ ¹× ¿ä¾à

±¤°í

  • Rating:
  • ƯÇã:
  • BSD License
  • °¡°Ý:
  • FREE
  • °Ô½ÃÀÚ À̸§:
  • Stefane Fermigier
  • °Ô½ÃÀÚ À¥»çÀÌÆ®:
  • http://www.fermigier.com/fermigier/tabulator.html.en

ÈÖ¹ßü ű×


ÈÖ¹ßü ¼³¸í

Whoshalchemy´Â SqlAlchemy ¸ðµ¨ ÇʵåÀÇ ½¬¿î ÅؽºÆ® À妽ÌÀ» Áö¿øÇÕ´Ï´Ù. Stefane Fermigier (http://www.fermigier.com/)°¡ ÀÛ¼ºÇÑ Flask-Whoshalchemy¸¦ ±â¹ÝÀ¸·ÎÇÕ´Ï´Ù. indexServiceStandard SqlAlchemy.ext.Declarative import.types¿¡¼­ sqlalchemy.types¿¡¼­ Sqlalchemy.types °¡Á® ¿À±â integer, text, datetime >>>¿¡¼­ sqlalchemy.Engine °¡Á® ¿À±â create_engine >>>¿¡¼­ sqlalchemy.orm.Session °¡Á® ¿À±â SessionMakerSetup SqlAlchemy : >>> Engine = create_engine ( 'sqlite : /// : memory :') >>> ¼¼¼Ç = sessionmaker (bind = ¿£Áø) >>> ¼¼¼Ç = session () >>> ±âÁö = drantrave_base () ¸ðµ¨ : >>> Ŭ·¡½º blogpost (base) : ... __tableName__ = 'blogpost'... __searchable__ = #ÀÌ Çʵå´Â whoosh .... .. ID = ¿­ (Á¤¼ö, primary_key = true) ... title = ¿­ (ÅؽºÆ®) ... Content = ¿­ (ÅؽºÆ®) ...... DEF __REPR __ (SELF) : ... ¹Ýȯ '{0} (title = {1}) '. Çü½Ä (¼¿ÇÁ .__ Ŭ·¡½º __.__ name__, self.title) ... >>> Base.Metadata.Create_all (¿£Áø) »ý¼º ¹× int inking ¼­ºñ½º : >>> config = { "whosh_base": "/ tmp / whoosh"}> >> index_service = indexservice (config = config, session = session) >>> index_service.register_class (blogpost) fileIndex (filestorage ( '/ tmp / whoosh / blogpost),'main ') ºí·Î±× °Ô½Ã¹° ¸¸µé±â : >>> m = BlogPost (title = u'my cool title ', content = u'this´Â ù ¹ø° °Ô½Ã¹°ÀÔ´Ï´Ù.') >>> ¼¼¼Ç .add (m); session.commit () ¸î °¡Áö °Ë»öÀ» ¼öÇàÇÕ´Ï´Ù. >>> ¸ñ·Ï (blogpost.search_query (u'cool ') >>> ¸ñ·Ï (blogpost.search_query (u'first')) Âü°í : ÀÀ´äÀº ±â»ç Äõ¸® °´Ã¼À̹ǷΠ´Ù¸¥ SQL ÀÛ¾÷À» Ãß°¡ÇÕ´Ï´Ù. >>> ¸ñ·Ï (blogpost.search_query (u'first ') ÇÊÅÍ (blogpost.id> = 0) )) FlaskSetupÀ» »ç¿ëÇÏ¿© Çöó½ºÅ© ¾ÛÀ» »ç¿ëÇÏ¿© DB °´Ã¼ (DB = SQLALCHEMY (APP))¸¦ ÀÛ¼ºÇÏ°í MODELS.SETSED_BASE¸¦ Çöó½ºÅ©ÀÇ WHOOSH À妽º µð·ºÅ丮·Î °¡Á®¿Â ´ÙÀ½¸¦ ¸¸µì´Ï´Ù. À妽º ¼­ºñ½º ¹× ¸ðµ¨ µî·Ï : >>> index_service = indexservice (config = app.config) >>> index_service.register_class (myfirstmodel) >>> index_service.register_class (mysecondmodel) etc.productÀÇ È¨ÆäÀÌÁö


ÈÖ¹ßü °ü·Ã ¼ÒÇÁÆ®¿þ¾î