Skip to content

Simple SQL and Mongo Query Generator for search strings

Notifications You must be signed in to change notification settings

aj-jaiswal007/query_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Query Generator

Query Generator is a mini module to generate SQL and Mongo text search queries from simple AND | OR search expressions.

For example

You have a DB table named Resume In that table there is a column name raw_content And you want to filter those resumes which have the words python OR java in it.

So your search string will be in that case

python OR java

This will generate the following SQL and MongoDB queries:

MONGO FILTER QUERY:
{'$or': [{'raw_content': {'$regex': 'python', '$options': 'i'}}, {'raw_content': {'$regex': 'java', '$options': 'i'}}]}


SQL QUERY:
SELECT * FROM "Resume" WHERE ("Resume"."raw_content" iLIKE %python% OR "Resume"."raw_content" iLIKE %java%) ;

How to test

  • Clone the respository
  • Run command python3 main.py test to run pre-defined test cases
  • Run command python3 main.py to test query generator for multiple custom inputs
  • Please note that AND and OR are case sensitive, using and and or won't work

About

Simple SQL and Mongo Query Generator for search strings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages