Table of Contents

Introduction Installation Projects Tables Inserts Searches Updates Deletes CLI Production Installation Partial Autoscaling Good Practices Conclusion

Searches - Flaarum Tutorials (Python)    Golang

Flaarum provides statements for different searches. This makes searches more comfortable than using a function call.

Sample Code


import pyflaarum

cl = pyflaarum.flaacl("127.0.0.1", "not-yet-ready", "first_proj")

try:
  cl.ping()
except:
  print("error connecting")


stmt = '''table: inbox
limit: 100
'''
try:
  rows = cl.search(stmt)
  emails = []
  for row in rows:
    emails.append(row["reply_to"])
  print(emails)
except pyflaarum.flaa_error as fe:
  print("Server error", fe.code, fe.message)
except Exception as e:
  print("python error")
  print(e.message)

Sample Search Statements

  1. table: users
    fields: name email
    limit: 10
    start_index: 50
    order_by: name asc
    
  2. table: users distinct
    fields: name
    limit: 150
    
  3. table: grades expand
    fields: userid.firstname userid.surname grade
    order_by: userid.firstname
    where:
      userid.age > 20
      and userid.age < 50
    

    A Where statement can take either and, or. Not both of them

  4. a where condition that contains space.

    table: grades
    where:
      score < 90
      and remark = 'not suspicious'
    
  5. in queries

    table: users
    where:
      id in 1 13 15 3
      and name in 'James John' 'John Paul' 'Paulo liv'
    
  6. has queries

    table: testtable
    where:
      stringd has 'going home'	
    
  7. has queries doesn't use an index. So are generally slower than other queries

    has queries only operates on string and text data types.

  8. Compound Queries

    table: t1
    joiner: or
    where1:
      id > 1
      and id < 3
    ::
    where2:
      userid > 16
      and userid < 323
    ::
    where3:
      score > 300
      and score < 600
    ::
    	

    Compound queries expects a joiner which takes the value of either and, or

    Compound queries can have upto to four where statements

< Previous Next >