-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(example.py): demonstration file for working with handlers
Signed-off-by: Harshal Chaudhari <[email protected]>
- Loading branch information
1 parent
782a950
commit ae75366
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |