TablePlus

Modern, Native Tool for Database Management

Docs:

Using since 2020 to manage my local SQLite databases.

Filter

03 Aug 2025

Can filter a table with the code below, but not clear yet how to open a SQL query:

import urllib.parse

# Base connection URL (without query parameters) > in Connections, right-click and "Copy as URL"
base_url = "sqlite://@%2FUsers%2FXXXX%2FXX%2FXXXX/btob.db"

# SQL query
query = '''
vip = 1
'''

# URL encode the query
encoded_query = urllib.parse.quote(query.strip())

table = 'people'

# Build the complete URL with all parameters
params = {
    'statusColor': '007F3D',
    'env': 'local',
    'name': 'BtoB',
    'tLSMode': '0',
    'usePrivateKey': 'false',
    'safeModeLevel': '0',
    'advancedSafeModeLevel': '0',
    'driverVersion': '0',
    'lazyload': 'false',
    'table': table,
    'condition': encoded_query
}

# Create the full URL
url_parts = [base_url]
if params:
    param_strings = [f"{key}={value}" for key, value in params.items()]
    url_parts.append("?" + "&".join(param_strings))

full_url = "".join(url_parts)

print(f"Encoded query: {encoded_query}")
print(f"\nFull URL with query:\n{full_url}")

# Open in TablePlus
import os
command = f'open -a TablePlus "{full_url}"'
print(f"\nExecuting command: {command}\n")
os.system(command)

links

social