mirror of
				https://github.com/kevinveenbirkenbach/baserow-ifto.git
				synced 2025-10-31 09:49:04 +00:00 
			
		
		
		
	Refactored file structure
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								__pycache__/baserow_api.cpython-311.pyc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								__pycache__/baserow_api.cpython-311.pyc
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -1,5 +1,4 @@ | ||||
| import requests | ||||
| import argparse | ||||
| import json | ||||
| 
 | ||||
| class BaserowAPI: | ||||
| @@ -115,38 +114,4 @@ class BaserowAPI: | ||||
| 
 | ||||
|         if self.verbose: | ||||
|             print("Merged Tables Data:", tables_data) | ||||
|         return tables_data | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|     parser = argparse.ArgumentParser(description="Fetch all data from a Baserow database.") | ||||
|     parser.add_argument("base_url", help="Base URL of your Baserow instance, e.g., https://YOUR_BASEROW_INSTANCE_URL/api/") | ||||
|     parser.add_argument("api_key", help="Your Baserow API key.") | ||||
|     parser.add_argument("--database_id", help="ID of the Baserow database you want to fetch data from.", default=None) | ||||
|     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("--quiet", action="store_true", help="Suppress output of json") | ||||
| 
 | ||||
|     args = parser.parse_args() | ||||
|     api = BaserowAPI(args.base_url, args.api_key, args.verbose) | ||||
| 
 | ||||
|     if not args.database_id and not args.table_ids: | ||||
|         print("Error: Either database_id or table_ids must be provided.") | ||||
|         exit(1) | ||||
| 
 | ||||
|     if args.table_ids: | ||||
|         table_ids = args.table_ids.split(',') | ||||
|         tables_data = {} | ||||
|         for table_id in table_ids: | ||||
|             table_data = api.get_all_rows_from_table(table_id.strip()) | ||||
|             tables_data[table_id] = table_data | ||||
| 
 | ||||
|         if args.matrix: | ||||
|             merged_data = api.merge_tables_on_reference(tables_data) | ||||
|             if not args.quiet: print(json.dumps(merged_data, indent=4)) | ||||
|         else: | ||||
|             if not args.quiet: print(json.dumps(tables_data, indent=4)) | ||||
|     else: | ||||
|         all_data = api.get_all_data_from_database(args.database_id) | ||||
|         if not args.quiet: print(json.dumps(all_data, indent=4)) | ||||
|         return tables_data | ||||
							
								
								
									
										37
									
								
								main.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								main.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| import argparse | ||||
| import json | ||||
|  | ||||
| from baserow_api import BaserowAPI | ||||
|  | ||||
| if __name__ == "__main__": | ||||
|     parser = argparse.ArgumentParser(description="Fetch all data from a Baserow database.") | ||||
|     parser.add_argument("base_url", help="Base URL of your Baserow instance, e.g., https://YOUR_BASEROW_INSTANCE_URL/api/") | ||||
|     parser.add_argument("api_key", help="Your Baserow API key.") | ||||
|     parser.add_argument("--database_id", help="ID of the Baserow database you want to fetch data from.", default=None) | ||||
|     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("--quiet", action="store_true", help="Suppress output of json") | ||||
|  | ||||
|     args = parser.parse_args() | ||||
|     api = BaserowAPI(args.base_url, args.api_key, args.verbose) | ||||
|  | ||||
|     if not args.database_id and not args.table_ids: | ||||
|         print("Error: Either database_id or table_ids must be provided.") | ||||
|         exit(1) | ||||
|  | ||||
|     if args.table_ids: | ||||
|         table_ids = args.table_ids.split(',') | ||||
|         tables_data = {} | ||||
|         for table_id in table_ids: | ||||
|             table_data = api.get_all_rows_from_table(table_id.strip()) | ||||
|             tables_data[table_id] = table_data | ||||
|  | ||||
|         if args.matrix: | ||||
|             merged_data = api.merge_tables_on_reference(tables_data) | ||||
|             if not args.quiet: print(json.dumps(merged_data, indent=4)) | ||||
|         else: | ||||
|             if not args.quiet: print(json.dumps(tables_data, indent=4)) | ||||
|     else: | ||||
|         all_data = api.get_all_data_from_database(args.database_id) | ||||
|         if not args.quiet: print(json.dumps(all_data, indent=4)) | ||||
		Reference in New Issue
	
	Block a user