Skip to content

Commit

Permalink
docs(example.py): demonstration file for working with handlers
Browse files Browse the repository at this point in the history
Signed-off-by: Harshal Chaudhari <[email protected]>
  • Loading branch information
harshalchaudhari35 committed Mar 27, 2023
1 parent 782a950 commit ae75366
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

from yapyfuzz.core import Fuzzy
from yapyfuzz.handler import ListHandler, SQLiteHandler, PostgresHandler
import os

root_dir = os.path.abspath(__file__)

terms = ["hello", "world", "foo", "bar"]
list_handler = ListHandler()
list_handler.reader(terms)

name = f"{root_dir}/yapy/fuzzy.db"
query = "select * from albums"
db_handler = SQLiteHandler()
db_handler.reader(name, query)

db_settings = {
"user":"postgres",
"password":"postgres",
"host":"localhost",
"port":"5432",
"dbname":"dellstore",
}

pg_handler = PostgresHandler()
# pg_handler.reader(query="select table_schema, table_name from information_schema.tables")
pg_handler.reader(query="select * from categories", **db_settings)
pg_handler.reader(query="select * from inventory", **db_settings)

fp = Fuzzy(pg_handler)
fp.get_selection()

fp = Fuzzy(list_handler)
fp.get_selection()

fp = Fuzzy(db_handler)
fp.get_selection()


# output = os.popen(
# "sqlite3 /home/harshal/Works/oss_projects/pyfuzzy/pyfuzzy/fuzzy.db \"select * from albums\""
# ).read().encode("utf-8")
# type(output)

0 comments on commit ae75366

Please sign in to comment.