Create and customize intelligent queries that answer questions about your data
Once you’ve connected your database, Infactory helps you create queries that answer specific questions about your data. These queries form the foundation of your AI-powered data experiences.
The Build page is your command center for creating and managing queries.
The Build page consists of these main components:
After connecting a data source, Infactory automatically generates approximately 12 queries based on your data schema.
Depending on your data, Infactory may generate queries such as:
Calculations like averages, sums, or counts grouped by categories
Finding records that match specific criteria or conditions
Ordering data by specific metrics (highest, lowest, etc.)
Examining relationships between different numeric fields
Analyzing trends over time periods
Comparing values across different categories
To test an autogenerated query:
Select a query
Click on a query from the list to load it in the query editor.
Review the query code
Examine the query code to understand what it does. Don’t worry if you’re not familiar with Python – the code is well-commented.
Run the query
Click the Run button to execute the query against your data.
View the results
The structured data results will appear in the Results Panel.
“Slots” are what make Infactory queries so powerful. They are placeholders in queries that can be filled with different values, making a single query capable of answering many related questions.
For example, a query with the question pattern “What is the average by ?” has two slots:
This means one query template can answer hundreds of specific questions like:
Infactory supports various slot types:
For text/string values like names, categories, or IDs
For numbers like thresholds, counts, or measurements
For date/time values like ranges or specific points in time
For selecting specific database columns or fields
For true/false options
For multiple values
While autogenerated queries cover many common scenarios, you may want to create custom queries for specific needs.
The easiest way to create a new query is with the Infactory Assistant:
Click New Query
Click the New Query button at the top of the query list.
Describe what you want
In the assistant panel, describe in natural language what you want the query to do.
Example: “Create a query that finds the correlation between player height and scoring average, grouped by position.”
Review the generated code
The assistant will generate query code based on your description. Review it to ensure it matches your intent.
Test the query
Click Run to test the query with your data.
Refine if needed
If the query doesn’t work as expected, you can:
For advanced users comfortable with Python, you can create queries manually:
Click New Query
Click the New Query button at the top of the query list.
Write your query code
Write your Python code in the query editor. The code should follow this structure:
Define slots (parameters)
In the Parameters section, define the slots your query will use.
Test your query
Click Run to test your query with sample parameter values.
Save your query
Give your query a descriptive name and save it.
Understanding the structure of query code helps you create and customize queries effectively.
All Infactory queries follow this basic structure:
Here are some common patterns used in query code:
Infactory’s query system provides several advanced features for complex scenarios.
Queries can combine data from multiple tables or collections:
You can create new fields based on calculations:
Combine multiple filters for complex query conditions:
You can format and structure your query results for optimal use:
For larger datasets, consider these optimization techniques:
Apply filters as early as possible to reduce the amount of data being processed:
Only load the columns you need for your query:
Prefer vectorized operations over loops:
When your query doesn’t work as expected, these debugging strategies can help:
Print Intermediate Results
Add print statements to see intermediate results during query execution:
The print outputs will appear in the console below the results panel.
Check Parameter Values
Verify that your parameters contain the expected values:
Examine Data Sample
Look at a sample of your data to ensure it contains what you expect:
Try Simpler Versions
If a complex query isn’t working, try a simpler version first:
Use autogenerated queries as templates for your custom queries whenever possible.
Give your queries clear names that describe what they do.
Document your query code with clear comments explaining what each section does.
Test your queries with extreme or unusual parameter values.
Validate parameter values and handle invalid inputs gracefully.
Design queries with slots that maximize their reusability.
After building your queries, the next step is to deploy them as API endpoints. Continue to Deploying APIs to learn how to make your queries available for applications to use.
Create and customize intelligent queries that answer questions about your data
Once you’ve connected your database, Infactory helps you create queries that answer specific questions about your data. These queries form the foundation of your AI-powered data experiences.
The Build page is your command center for creating and managing queries.
The Build page consists of these main components:
After connecting a data source, Infactory automatically generates approximately 12 queries based on your data schema.
Depending on your data, Infactory may generate queries such as:
Calculations like averages, sums, or counts grouped by categories
Finding records that match specific criteria or conditions
Ordering data by specific metrics (highest, lowest, etc.)
Examining relationships between different numeric fields
Analyzing trends over time periods
Comparing values across different categories
To test an autogenerated query:
Select a query
Click on a query from the list to load it in the query editor.
Review the query code
Examine the query code to understand what it does. Don’t worry if you’re not familiar with Python – the code is well-commented.
Run the query
Click the Run button to execute the query against your data.
View the results
The structured data results will appear in the Results Panel.
“Slots” are what make Infactory queries so powerful. They are placeholders in queries that can be filled with different values, making a single query capable of answering many related questions.
For example, a query with the question pattern “What is the average by ?” has two slots:
This means one query template can answer hundreds of specific questions like:
Infactory supports various slot types:
For text/string values like names, categories, or IDs
For numbers like thresholds, counts, or measurements
For date/time values like ranges or specific points in time
For selecting specific database columns or fields
For true/false options
For multiple values
While autogenerated queries cover many common scenarios, you may want to create custom queries for specific needs.
The easiest way to create a new query is with the Infactory Assistant:
Click New Query
Click the New Query button at the top of the query list.
Describe what you want
In the assistant panel, describe in natural language what you want the query to do.
Example: “Create a query that finds the correlation between player height and scoring average, grouped by position.”
Review the generated code
The assistant will generate query code based on your description. Review it to ensure it matches your intent.
Test the query
Click Run to test the query with your data.
Refine if needed
If the query doesn’t work as expected, you can:
For advanced users comfortable with Python, you can create queries manually:
Click New Query
Click the New Query button at the top of the query list.
Write your query code
Write your Python code in the query editor. The code should follow this structure:
Define slots (parameters)
In the Parameters section, define the slots your query will use.
Test your query
Click Run to test your query with sample parameter values.
Save your query
Give your query a descriptive name and save it.
Understanding the structure of query code helps you create and customize queries effectively.
All Infactory queries follow this basic structure:
Here are some common patterns used in query code:
Infactory’s query system provides several advanced features for complex scenarios.
Queries can combine data from multiple tables or collections:
You can create new fields based on calculations:
Combine multiple filters for complex query conditions:
You can format and structure your query results for optimal use:
For larger datasets, consider these optimization techniques:
Apply filters as early as possible to reduce the amount of data being processed:
Only load the columns you need for your query:
Prefer vectorized operations over loops:
When your query doesn’t work as expected, these debugging strategies can help:
Print Intermediate Results
Add print statements to see intermediate results during query execution:
The print outputs will appear in the console below the results panel.
Check Parameter Values
Verify that your parameters contain the expected values:
Examine Data Sample
Look at a sample of your data to ensure it contains what you expect:
Try Simpler Versions
If a complex query isn’t working, try a simpler version first:
Use autogenerated queries as templates for your custom queries whenever possible.
Give your queries clear names that describe what they do.
Document your query code with clear comments explaining what each section does.
Test your queries with extreme or unusual parameter values.
Validate parameter values and handle invalid inputs gracefully.
Design queries with slots that maximize their reusability.
After building your queries, the next step is to deploy them as API endpoints. Continue to Deploying APIs to learn how to make your queries available for applications to use.