diff --git a/.gitignore b/.gitignore index 94a2dd1..585b27a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*.json \ No newline at end of file +*.json +__pycache__ \ No newline at end of file diff --git a/__pycache__/baserow_api.cpython-311.pyc b/__pycache__/baserow_api.cpython-311.pyc deleted file mode 100644 index fa1bda2..0000000 Binary files a/__pycache__/baserow_api.cpython-311.pyc and /dev/null differ diff --git a/baserow_api.py b/baserow_api.py index 842ac20..90b6762 100644 --- a/baserow_api.py +++ b/baserow_api.py @@ -40,10 +40,10 @@ class BaserowAPI: if self.verbose: print(f"[INFO] Fetching all rows from table with ID: {table_id}...") rows = [] - next_url = f"{self.base_url}database/rows/table/{table_id}/" + next_url = "database/rows/table/{table_id}/" while next_url: - response = requests.get(next_url, headers=self.headers) + request_response(next_url) self.print_verbose_message("Requesting:", next_url) data = self.handle_api_response(response) if not data: @@ -53,9 +53,12 @@ class BaserowAPI: return rows + def request_response(self,command): + return requests.get(f"{self.base_url}{command}", headers=self.headers) + def get_all_tables_from_database(self, database_id): self.print_verbose_message("[INFO] Fetching all tables from database with ID: {database_id}...") - response = requests.get(f"{self.base_url}database/tables/database/{database_id}/", headers=self.headers) + response = request_response("database/tables/database/{database_id}/") return self.handle_api_response(response) or [] def get_all_data_from_database(self, database_id): diff --git a/main.py b/main.py index 6e322ab..1f54bc4 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,7 @@ if __name__ == "__main__": parser.add_argument("--table_ids", help="IDs of the Baserow tables you want to fetch data from, separated by commas.", default=None) parser.add_argument("--matrix", action="store_true", help="Merge tables based on references.") parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose mode for debugging.") + parser.add_argument("--linked_fields", action="store_true", help="Outputs the linked tables") parser.add_argument("--quiet", action="store_true", help="Suppress output of json") args = parser.parse_args()