mirror of
				https://github.com/lubuntu-team/metrics.git
				synced 2025-10-30 21:44:16 +00:00 
			
		
		
		
	Make the commands to be ran a list.
This commit is contained in:
		
							parent
							
								
									0fbe46ecdc
								
							
						
					
					
						commit
						11a23f817f
					
				
							
								
								
									
										15
									
								
								metrics
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								metrics
									
									
									
									
									
								
							| @ -29,22 +29,29 @@ def sqlite_run(command, db=":memory:", return_output=False): | |||||||
|     """ |     """ | ||||||
|     conn = sqlite3.connect(db) |     conn = sqlite3.connect(db) | ||||||
|     c = conn.cursor() |     c = conn.cursor() | ||||||
|     c.execute(command) |     for cmd in command: | ||||||
|  |         c.execute(cmd) | ||||||
|     conn.commit() |     conn.commit() | ||||||
| 
 | 
 | ||||||
|     # Make sure we return an output if requested |     # Make sure we return an output if requested | ||||||
|  |     try: | ||||||
|         if return_output: |         if return_output: | ||||||
|             rows = c.fetchall() |             rows = c.fetchall() | ||||||
|             return rows |             return rows | ||||||
| 
 |     except Exception as e: | ||||||
|  |         print(e) | ||||||
|  |     finally: | ||||||
|         conn.close() |         conn.close() | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def main(module): | def main(module): | ||||||
|     """Given a specific module, set it up and insert recent values""" |     """Given a specific module, set it up and insert recent values""" | ||||||
|     module = module() |     module = module() | ||||||
|     sqlite_run(module.sqlite_setup()) |     run = [] | ||||||
|     sqlite_run(module.sqlite_add()) |     run.append(module.sqlite_setup()) | ||||||
|  |     run.append(module.sqlite_add()) | ||||||
|  |     run.append(module.sqlite_time_range(days=10)) | ||||||
|  |     print(sqlite_run(run, return_output=True)) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| if __name__ == "__main__": | if __name__ == "__main__": | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user