Query and retrieve records from database tables with flexible filtering, type-safe results, and cross-database compatibility.
The find()
method retrieves records from database tables. It supports flexible filtering conditions, returns type-safe results as dictionaries, and works consistently across all supported databases including MongoDB.
find(table_name: str, filters: Optional[Dict[str, Any]] = None) -> List[Dict[str, Any]]
Type: str
Name of the table to query. The table must exist before querying.
Type: Optional[Dict[str, Any]]
Default: None
Dictionary mapping column names to values for filtering results. If None or empty, returns all records in the table. Supports exact value matching.
None
- Returns all records
- Returns all records{"column": value}
- Returns records where column equals value{"col1": val1, "col2": val2}
- Returns records matching all conditions (AND)Type: List[Dict[str, Any]]
List of dictionaries, where each dictionary represents a record with column names as keys and their corresponding values. Returns an empty list if no records match the filters.
All users: {'id': 1, 'username': 'alice', 'email': 'alice@example.com', 'age': 28, 'active': True} {'id': 2, 'username': 'bob', 'email': 'bob@example.com', 'age': 32, 'active': False} {'id': 3, 'username': 'charlie', 'email': 'charlie@example.com', 'age': 25, 'active': True} Total users: 3
Use filters to find specific records:
Active users: alice (age 28) charlie (age 25) User with ID 2: [{'id': 2, 'username': 'bob', 'email': 'bob@example.com', 'age': 32, 'active': False}] User 'alice': [{'id': 1, 'username': 'alice', 'email': 'alice@example.com', 'age': 28, 'active': True}] Users age 25: [{'id': 3, 'username': 'charlie', 'email': 'charlie@example.com', 'age': 25, 'active': True}]
Use multiple filter conditions to narrow down results:
Active users age 28: [{'id': 1, 'username': 'alice', 'email': 'alice@example.com', 'age': 28, 'active': True}] Inactive user named bob: [{'id': 2, 'username': 'bob', 'email': 'bob@example.com', 'age': 32, 'active': False}] Users active and age 50: []
Query tables with foreign key relationships:
Posts by Jane Doe (1): 'Python Tips' - Published: True, Views: 150 'Database Design' - Published: False, Views: 45 Published posts: 2 Popular published posts: [{'id': 3, 'title': 'Web Development', 'content': 'Modern frameworks...', 'author_id': 2, 'published': True, 'views': 200}]
Work with the returned data efficiently:
Usernames: ['alice', 'bob', 'charlie'] Adult users: 1 Average age: 28.3 Found Alice: alice@example.com Has inactive users: True
Uses standard SQL SELECT statements with WHERE clauses:
Uses MySQL-compatible SQL with proper parameter binding:
Uses PostgreSQL syntax with proper type handling:
Translates filters to MongoDB query documents:
Table not found: no such table: nonexistent_table Table 'missing_table' does not exist
Query data using raw SQL with the Akron CLI:
(1, 'alice', 'alice@example.com', 28, 1) (2, 'bob', 'bob@example.com', 32, 0) (3, 'charlie', 'charlie@example.com', 25, 1) SQL executed.
After retrieving data, you can modify or remove it: