commit 24ddfb31e4107b9da621020302c42be9a91e7077 Author: cato447 Date: Thu Sep 2 01:07:37 2021 +0200 Implemented getting data from notion database diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d2127d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.ini diff --git a/main.py b/main.py new file mode 100644 index 0000000..b3e7411 --- /dev/null +++ b/main.py @@ -0,0 +1,23 @@ +import configparser + +from notion.client import * +from notion.collection import NotionDate + +import pandas as pd + +def main(): + config = configparser.ConfigParser() + config.read('credentials.ini') + + client = NotionClient(token_v2=config.get("notion", "token")) + + # Access a database using the URL of the database page or the inline block + cv = client.get_collection_view(config.get("notion", "database_url")) + + print(get_all_available_items(cv)) + +def get_all_available_items(cv): + return [row.name for row in cv.collection.get_rows() if int(row.anzahl) > 0] + +if __name__ == '__main__': + main() \ No newline at end of file