Skip to main content
The line_crossing_events_reader data action reads visitor entry and exit events from the local RESDB SQLite database. It queries the visitor_entries table populated by the visitor_entry_counting action.

What it does

The line crossing reader:
  1. Accepts custom SELECT queries via feature_variables.select_query
  2. Validates query safety to prevent write operations
  3. Executes the query against the visitor_entries table
  4. Parses JSON columns like raw_data
  5. Computes convenience fields like event_type, gender, and age_range
  6. Returns all matching records in a single response

Requirements

RequirementDescription
select_queryA valid SELECT query in feature_variables. Required.
RESDB databaseThe local SQLite database must be initialized

Configuration

Configure the action through feature_variables on the action detail:
VariableTypeRequiredDescription
select_querystringYesFull SELECT query to execute
The query must start with SELECT. Any write operations are blocked for security.

Available columns

The visitor_entries table contains these columns:
ColumnTypeDescription
idintegerAuto-incrementing primary key
timestampdatetimeWhen the event occurred
camera_nametextName of the camera/stream
entry_countinteger1 if this is an entry event, 0 otherwise
exit_countinteger1 if this is an exit event, 0 otherwise
male_countinteger1 if person is male, 0 otherwise
female_countinteger1 if person is female, 0 otherwise
age_0_10integer1 if age is 0-10, 0 otherwise
age_10_20integer1 if age is 10-20, 0 otherwise
age_20_30integer1 if age is 20-30, 0 otherwise
age_30_40integer1 if age is 30-40, 0 otherwise
age_40_50integer1 if age is 40-50, 0 otherwise
age_50_60integer1 if age is 50-60, 0 otherwise
age_60_plusinteger1 if age is 60+, 0 otherwise
wide_rangetextOriginal wide age range if AI gave broad estimate
raw_datatext (JSON)Additional metadata (entry_type, gender, age_range, stream_id)
stream_idintegerID of the stream where event was detected
entry_line_idintegerID of the entry line configuration
is_readbooleanWhether the record has been processed

Example queries

Query entries in the last hour

Find all entry events from the past hour: Query:
SELECT * FROM visitor_entries 
WHERE entry_count = 1 
AND timestamp > datetime('now', '-1 hour') 
ORDER BY timestamp DESC
Use case: Real-time monitoring of store entries.

Query exits today

Find all exit events from today: Query:
SELECT * FROM visitor_entries 
WHERE exit_count = 1 
AND date(timestamp) = date('now') 
ORDER BY timestamp DESC
Use case: Daily exit count reporting.

Query by gender

Find all male entries: Query:
SELECT * FROM visitor_entries 
WHERE entry_count = 1 
AND male_count = 1 
AND timestamp > datetime('now', '-24 hours') 
ORDER BY timestamp DESC
Use case: Demographic analysis of visitors.

Query by age group

Find visitors in the 20-30 age range: Query:
SELECT * FROM visitor_entries 
WHERE age_20_30 = 1 
AND timestamp > datetime('now', '-24 hours') 
ORDER BY timestamp DESC
Use case: Age-based visitor analysis.

Count entries by hour

Get hourly entry counts for today: Query:
SELECT strftime('%H', timestamp) as hour, 
       SUM(entry_count) as entries, 
       SUM(exit_count) as exits 
FROM visitor_entries 
WHERE date(timestamp) = date('now') 
GROUP BY hour 
ORDER BY hour
Use case: Traffic pattern analysis throughout the day.

Count by demographics

Get gender and age breakdown: Query:
SELECT 
    SUM(male_count) as males, 
    SUM(female_count) as females,
    SUM(age_0_10) as age_0_10,
    SUM(age_10_20) as age_10_20,
    SUM(age_20_30) as age_20_30,
    SUM(age_30_40) as age_30_40,
    SUM(age_40_50) as age_40_50,
    SUM(age_50_60) as age_50_60,
    SUM(age_60_plus) as age_60_plus
FROM visitor_entries 
WHERE timestamp > datetime('now', '-24 hours')
Use case: Daily demographic summary report.

Query by specific camera

Find events from a specific camera: Query:
SELECT * FROM visitor_entries 
WHERE camera_name = 'Main Entrance' 
AND timestamp > datetime('now', '-1 hour') 
ORDER BY timestamp DESC 
LIMIT 100
Use case: Camera-specific visitor analysis.

Query unprocessed entries

Find entries that haven’t been synchronized: Query:
SELECT * FROM visitor_entries 
WHERE is_read = 0 
ORDER BY timestamp ASC 
LIMIT 500
Use case: Batch upload to central database.

Result format

Success with records

FieldValue
is_successtrue
feature_resultrecords_found
note”Found X line crossing event records”
extras.recordsArray of record objects
extras.total_recordsNumber of records returned
extras.query_usedThe executed query (truncated if long)
extras.columnsArray of column names

No records found

FieldValue
is_successtrue
feature_resultno_records_found
note”No line crossing event records found matching criteria”
extras.recordsEmpty array
extras.total_records0

Record structure

Each record in extras.records contains:
FieldDescription
All database columnsOriginal column values
record_idCopy of id for convenience
event_typeComputed: 'entry' or 'exit'
genderComputed: 'Male', 'Female', or 'Unknown'
age_rangeComputed: '0-10', '10-20', …, '60+', or 'Unknown'
is_entrytrue if entry_count is 1
is_exittrue if exit_count is 1
raw_dataParsed JSON object (if present)

Possible errors

Error: no_query_providedWhat happened: The select_query feature variable was not set.How to fix: Add a select_query to the action’s feature_variables configuration.
Error: invalid_queryWhat happened: The query doesn’t start with SELECT or contains forbidden keywords.How to fix:
  • Ensure query starts with SELECT
  • Remove any INSERT, UPDATE, DELETE, DROP, or other write statements
Error: errorWhat happened: SQL execution failed due to syntax error or database issue.How to fix:
  • Verify SQL syntax is valid SQLite
  • Check column names exist in the table
  • Ensure database file is accessible

Data flow

The visitor entry data flows through the system as follows:
1

Detection

The visitor_entry_counting action detects people crossing virtual lines using YOLO models.
2

Demographic analysis

For each crossing, gender and age are estimated via RunPod AI analysis.
3

Storage

Events are stored in the visitor_entries table with all demographic flags.
4

Querying

The line_crossing_events_reader queries events for reporting or further processing.
5

Synchronization

A separate action uploads unread records to the central Supabase database.
The computed fields (event_type, gender, age_range) are added by the reader for convenience. They’re derived from the flag columns and not stored in the database.