HeliosDB Nano SQLite Compatibility Troubleshooting Guide
HeliosDB Nano SQLite Compatibility Troubleshooting Guide
This guide helps you quickly resolve common issues when using HeliosDB Nano as a SQLite drop-in replacement.
Table of Contents
- Installation Issues
- Import and Module Errors
- Compatibility Issues
- Performance Problems
- Data Migration Issues
- Mode Switching Issues
- Connection and Threading Issues
- Testing and Debugging Tips
Installation Issues
Problem: pip install fails
Symptoms:
$ pip install heliosdb-sqliteERROR: Could not find a version that satisfies the requirement heliosdb-sqliteSolutions:
- Update pip and setuptools:
python -m pip install --upgrade pip setuptools wheelpip install heliosdb-sqlite- Check Python version:
python --version # Must be Python 3.8 or higher- Try specific version:
pip install heliosdb-sqlite==1.0.0- Install from source (if pre-built wheels unavailable):
git clone https://github.com/dimensigon/HDB-HeliosDB-Nano.gitcd heliosdb-nano/pythonpip install .Problem: Import works in terminal but not in IDE
Symptoms:
# Works in terminal$ python -c "import heliosdb_sqlite"
# Fails in PyCharm/VSCodeModuleNotFoundError: No module named 'heliosdb_sqlite'Solutions:
-
Verify IDE is using correct Python interpreter:
- PyCharm: Settings > Project > Python Interpreter
- VSCode: Select interpreter from command palette (Ctrl+Shift+P)
-
Install in IDE’s environment:
# Find IDE's Python pathwhich python
# Install there explicitly/path/to/ide/python -m pip install heliosdb-sqlite- Restart IDE after installation
Import and Module Errors
Problem: “No module named ‘heliosdb_sqlite’”
Symptoms:
import heliosdb_sqlite as sqlite3# ModuleNotFoundError: No module named 'heliosdb_sqlite'Solutions:
- Verify installation:
pip list | grep heliosdbpython -c "import heliosdb_sqlite; print(heliosdb_sqlite.__version__)"- Check virtual environment:
# Activate correct environmentsource venv/bin/activate # Linux/Macvenv\Scripts\activate # Windows
# Verifywhich pythonpip list- Reinstall package:
pip uninstall heliosdb-sqlitepip install heliosdb-sqliteProblem: AttributeError with HeliosDB Nano methods
Symptoms:
conn = sqlite3.connect('app.db')conn.some_method()# AttributeError: 'Connection' object has no attribute 'some_method'Solutions:
- Check if method is standard SQLite:
import sqlite3 as std_sqlite
# Check if method exists in standard SQLiteprint(dir(std_sqlite.connect(':memory:')))- Use HeliosDB Nano specific features correctly:
# Wrong: advanced features need to be enabledconn = sqlite3.connect('app.db')conn.create_branch('test') # May fail
# Right: enable advanced featuresconn = sqlite3.connect('app.db', heliosdb_mode='advanced')branch = conn.create_branch('test') # Works!- Check API documentation:
# Get help on connection objecthelp(conn)
# List all available methodsprint([m for m in dir(conn) if not m.startswith('_')])Compatibility Issues
Problem: Existing code breaks with HeliosDB Nano
Symptoms:
# Code worked with SQLite but fails with HeliosDB Nanocursor.execute('SELECT * FROM users')# Some error occursSolutions:
- Enable compatibility mode:
# Maximum SQLite compatibilityconn = sqlite3.connect('app.db', heliosdb_mode='sqlite_compat')- Check for unsupported features:
# Test basic operations one by oneimport heliosdb_sqlite as sqlite3
conn = sqlite3.connect(':memory:')cursor = conn.cursor()
# Test CREATEcursor.execute('CREATE TABLE test (id INTEGER, name TEXT)')print("CREATE: OK")
# Test INSERTcursor.execute('INSERT INTO test VALUES (1, "test")')conn.commit()print("INSERT: OK")
# Test SELECTcursor.execute('SELECT * FROM test')print(f"SELECT: {cursor.fetchall()}")
# Test UPDATEcursor.execute('UPDATE test SET name = "updated" WHERE id = 1')conn.commit()print("UPDATE: OK")
# Test DELETEcursor.execute('DELETE FROM test WHERE id = 1')conn.commit()print("DELETE: OK")- Use fallback pattern:
# Conditional import for safetytry: import heliosdb_sqlite as sqlite3 db_engine = 'heliosdb'except Exception as e: print(f"HeliosDB Nano failed ({e}), falling back to SQLite") import sqlite3 db_engine = 'sqlite'
print(f"Using: {db_engine}")Problem: SQL syntax not recognized
Symptoms:
cursor.execute('SELECT * FROM users LIMIT 10 OFFSET 5')# Syntax error or unexpected behaviorSolutions:
- Verify SQL is standard SQLite syntax:
# Test query in standard SQLite firstimport sqlite3 as std_sqlitetest_conn = std_sqlite.connect(':memory:')test_conn.execute('CREATE TABLE users (id INTEGER, name TEXT)')test_conn.execute('INSERT INTO users VALUES (1, "test")')result = test_conn.execute('SELECT * FROM users LIMIT 10 OFFSET 5')print(result.fetchall())- Check for HeliosDB Nano specific syntax:
# Some advanced features require enablingconn = sqlite3.connect('app.db', enable_time_travel=True)
# Now time-travel syntax workscursor.execute(''' SELECT * FROM users AS OF TIMESTAMP '2024-01-01 10:00:00'''')- Use parameterized queries:
# Instead of string formatting# cursor.execute(f'SELECT * FROM users WHERE id = {user_id}') # Bad
# Use parameterscursor.execute('SELECT * FROM users WHERE id = ?', (user_id,)) # GoodPerformance Problems
Problem: Queries are slower than SQLite
Symptoms:
# Query takes longer than expectedstart = time.time()cursor.execute('SELECT * FROM large_table')results = cursor.fetchall()print(f"Time: {time.time() - start:.2f}s") # Slower than SQLiteSolutions:
- Create appropriate indexes:
# Check if indexes existcursor.execute("SELECT name FROM sqlite_master WHERE type='index'")print("Existing indexes:", cursor.fetchall())
# Create missing indexescursor.execute('CREATE INDEX IF NOT EXISTS idx_user_email ON users(email)')cursor.execute('CREATE INDEX IF NOT EXISTS idx_post_date ON posts(created_at)')conn.commit()- Enable query caching:
# Enable result caching for read-heavy workloadsconn = sqlite3.connect('app.db', enable_cache=True, cache_size_mb=100)- Use batch operations:
# Slow: individual insertsfor user in users: cursor.execute('INSERT INTO users VALUES (?, ?)', user) conn.commit() # Don't commit each insert!
# Fast: batch with single commitfor user in users: cursor.execute('INSERT INTO users VALUES (?, ?)', user)conn.commit() # Single commit at end
# Fastest: executemanycursor.executemany('INSERT INTO users VALUES (?, ?)', users)conn.commit()- Analyze query plans:
# See how query is executedcursor.execute('EXPLAIN QUERY PLAN SELECT * FROM users WHERE email = ?', ('test@example.com',))plan = cursor.fetchall()print("Query plan:", plan)
# Look for "SCAN" (bad) vs "SEARCH" (good)# If you see SCAN, you probably need an index- Adjust connection settings:
# Tune for performanceconn = sqlite3.connect( 'app.db', isolation_level='DEFERRED', # Less locking check_same_thread=False, # Multi-threaded cached_statements=100, # Cache prepared statements timeout=30.0 # Longer timeout)
# Set pragmasconn.execute('PRAGMA journal_mode=WAL')conn.execute('PRAGMA synchronous=NORMAL')conn.execute('PRAGMA cache_size=10000')conn.execute('PRAGMA temp_store=MEMORY')Problem: High memory usage
Symptoms:
# Memory keeps growingconn = sqlite3.connect('app.db')# Memory usage increases over timeSolutions:
- Close connections properly:
# Use context managerwith sqlite3.connect('app.db') as conn: cursor = conn.cursor() cursor.execute('SELECT * FROM users') results = cursor.fetchall()# Connection automatically closed
# Or explicit closeconn = sqlite3.connect('app.db')try: # ... do work ...finally: conn.close()- Fetch data in chunks:
# Don't load all data at oncecursor.execute('SELECT * FROM large_table')
# Fetch in batchesbatch_size = 1000while True: rows = cursor.fetchmany(batch_size) if not rows: break process_rows(rows)- Limit cache size:
conn = sqlite3.connect('app.db', cache_size_mb=50) # Limit cache to 50MB- Vacuum database:
# Reclaim unused spaceconn.execute('VACUUM')Data Migration Issues
Problem: Can’t open existing SQLite database
Symptoms:
conn = sqlite3.connect('existing.db')# Error: database disk image is malformedSolutions:
- Check database integrity:
# Use SQLite CLI to checksqlite3 existing.db "PRAGMA integrity_check;"- Repair database:
# Export and reimportsqlite3 existing.db ".dump" > backup.sqlsqlite3 new.db < backup.sql
# Then use new.db with HeliosDB Nano- Check file permissions:
ls -la existing.db # Should be readable/writablechmod 644 existing.dbProblem: Data looks corrupted after switching to HeliosDB Nano
Symptoms:
# Data appears incorrect or missingcursor.execute('SELECT * FROM users')results = cursor.fetchall()# Results don't match expectationsSolutions:
- Verify with SQLite first:
import sqlite3 as std_sqlite
# Check with standard SQLitestd_conn = std_sqlite.connect('app.db')std_cursor = std_conn.cursor()std_cursor.execute('SELECT COUNT(*) FROM users')print(f"SQLite sees: {std_cursor.fetchone()[0]} users")
# Check with HeliosDB Nanoimport heliosdb_sqlitehdb_conn = heliosdb_sqlite.connect('app.db')hdb_cursor = hdb_conn.cursor()hdb_cursor.execute('SELECT COUNT(*) FROM users')print(f"HeliosDB Nano sees: {hdb_cursor.fetchone()[0]} users")- Check transaction isolation:
# Ensure proper transaction handlingconn = sqlite3.connect('app.db', isolation_level='DEFERRED')conn.execute('BEGIN')cursor = conn.cursor()cursor.execute('SELECT * FROM users')results = cursor.fetchall()conn.commit()- Flush caches:
# Force data to diskconn.commit()conn.execute('PRAGMA wal_checkpoint(FULL)')Mode Switching Issues
Problem: Can’t start server mode
Symptoms:
server = sqlite3.start_server('app.db', port=5432)# Error: Address already in useSolutions:
- Check if port is in use:
# Linux/Maclsof -i :5432netstat -tuln | grep 5432
# Windowsnetstat -ano | findstr :5432
# Kill existing process or use different port- Use different port:
server = sqlite3.start_server('app.db', port=5433) # Different port- Check permissions:
# Ensure you can bind to port (< 1024 needs root)sudo python your_script.py # If port < 1024
# Or use port > 1024server = sqlite3.start_server('app.db', port=8432)Problem: Hybrid mode not working
Symptoms:
conn = sqlite3.connect('app.db', heliosdb_mode='hybrid')# Can't connect remotely even though server should be runningSolutions:
- Check server info:
conn = sqlite3.connect('app.db', heliosdb_mode='hybrid')info = conn.get_server_info()print(f"Server running: {info.is_running}")print(f"Port: {info.port}")print(f"Host: {info.host}")- Check firewall:
# Linuxsudo ufw statussudo ufw allow 5432/tcp
# Check if server is listeningnetstat -tuln | grep 5432- Test connection:
# Try connecting with psqlpsql -h localhost -p 5432 -U helios app
# Or with Pythonimport psycopg2conn = psycopg2.connect(host='localhost', port=5432, database='app')Connection and Threading Issues
Problem: “SQLite objects created in a thread can only be used in that same thread”
Symptoms:
conn = sqlite3.connect('app.db')# Use connection from different thread# Error: SQLite objects created in a thread can only be used in that same threadSolutions:
- Disable thread checking:
conn = sqlite3.connect('app.db', check_same_thread=False)- Use connection per thread:
import threading
thread_local = threading.local()
def get_connection(): if not hasattr(thread_local, 'conn'): thread_local.conn = sqlite3.connect('app.db') return thread_local.conn
# Each thread gets its own connectiondef worker(): conn = get_connection() cursor = conn.cursor() cursor.execute('SELECT * FROM users')- Use connection pooling:
from heliosdb_sqlite import connection_pool
pool = connection_pool.create('app.db', pool_size=10)
def worker(): with pool.connection() as conn: cursor = conn.cursor() cursor.execute('SELECT * FROM users')Problem: Concurrent write deadlocks
Symptoms:
# Multiple threads trying to write# Some threads hang or timeoutSolutions:
- HeliosDB Nano should handle this, but if it happens:
# Increase timeoutconn = sqlite3.connect('app.db', timeout=30.0)
# Use retry logicimport time
def write_with_retry(query, params, max_retries=3): for attempt in range(max_retries): try: cursor.execute(query, params) conn.commit() return except sqlite3.OperationalError as e: if 'locked' in str(e) and attempt < max_retries - 1: time.sleep(0.1 * (2 ** attempt)) # Exponential backoff else: raise- Check if you’re actually using HeliosDB Nano:
import heliosdb_sqlite as sqlite3print(f"Using: {sqlite3.__name__}") # Should say 'heliosdb_sqlite'Testing and Debugging Tips
Enable debug logging
import heliosdb_sqlite as sqlite3import logging
# Enable debug logginglogging.basicConfig(level=logging.DEBUG)sqlite3.enable_debug_logging()
# Now all database operations are loggedconn = sqlite3.connect('app.db')cursor = conn.cursor()cursor.execute('SELECT * FROM users')Compare behavior with SQLite
import sqlite3 as std_sqliteimport heliosdb_sqlite as hdb_sqlite
def test_query(db_module, name): try: conn = db_module.connect(':memory:') cursor = conn.cursor()
cursor.execute('CREATE TABLE test (id INTEGER, value TEXT)') cursor.execute('INSERT INTO test VALUES (1, "hello")') conn.commit()
cursor.execute('SELECT * FROM test') result = cursor.fetchall()
print(f"{name}: {result}") conn.close() return True except Exception as e: print(f"{name} failed: {e}") return False
# Test bothtest_query(std_sqlite, "SQLite")test_query(hdb_sqlite, "HeliosDB Nano")Isolate the problem
# Minimal reproducible exampleimport heliosdb_sqlite as sqlite3
# Test with in-memory database (simpler)conn = sqlite3.connect(':memory:')cursor = conn.cursor()
# Test your exact failing querytry: cursor.execute('YOUR FAILING QUERY HERE') print("Query succeeded!")except Exception as e: print(f"Query failed: {e}") import traceback traceback.print_exc()Check HeliosDB Nano version and capabilities
import heliosdb_sqlite as sqlite3
print(f"HeliosDB Nano version: {sqlite3.__version__}")print(f"SQLite version: {sqlite3.sqlite_version}")
# Check available featuresconn = sqlite3.connect(':memory:')features = conn.get_features()print(f"Vector search: {features.vector_search}")print(f"Time-travel: {features.time_travel}")print(f"Branching: {features.branching}")print(f"Encryption: {features.encryption}")Generate diagnostic report
def generate_diagnostic_report(): import heliosdb_sqlite as sqlite3 import sys import platform
print("=== HeliosDB Nano Diagnostic Report ===\n")
print(f"Python version: {sys.version}") print(f"Platform: {platform.platform()}") print(f"HeliosDB Nano version: {sqlite3.__version__}") print(f"SQLite version: {sqlite3.sqlite_version}")
print("\nTesting basic operations...")
try: conn = sqlite3.connect(':memory:') cursor = conn.cursor()
cursor.execute('CREATE TABLE test (id INTEGER)') cursor.execute('INSERT INTO test VALUES (1)') cursor.execute('SELECT * FROM test') result = cursor.fetchall()
print(f"Basic operations: OK") print(f"Result: {result}")
conn.close() except Exception as e: print(f"Basic operations: FAILED") print(f"Error: {e}")
print("\n=== End Diagnostic Report ===")
# Run diagnosticgenerate_diagnostic_report()Getting Help
If you’ve tried these solutions and still have issues:
- Check GitHub Issues: https://github.com/dimensigon/HDB-HeliosDB-Nano/issues
- Ask on Stack Overflow: Tag with
heliosdb - Join Discord Community: Real-time help from users
- Email Support: support@heliosdb.io
When asking for help, include:
- HeliosDB Nano version (
sqlite3.__version__) - Python version
- Operating system
- Minimal code that reproduces the issue
- Full error message and traceback
- What you’ve already tried
Common Error Messages
”database is locked”
Cause: Multiple processes trying to write simultaneously (shouldn’t happen with HeliosDB Nano!)
Fix:
# Verify you're actually using HeliosDB Nanoimport heliosdb_sqlite as sqlite3print(sqlite3.__name__) # Should be 'heliosdb_sqlite'
# If confirmed HeliosDB Nano, increase timeoutconn = sqlite3.connect('app.db', timeout=30.0)“no such table”
Cause: Table doesn’t exist or transaction issues
Fix:
# List all tablescursor.execute("SELECT name FROM sqlite_master WHERE type='table'")print("Available tables:", cursor.fetchall())
# Create table if missingcursor.execute('CREATE TABLE IF NOT EXISTS users (id INTEGER, name TEXT)')“disk I/O error”
Cause: Permissions, disk space, or hardware issues
Fix:
# Check disk spacedf -h
# Check permissionsls -la database.db
# Check disk health# Linux: sudo smartctl -H /dev/sda# Mac: diskutil verifyVolume /Prevention Tips
- Always use context managers:
with sqlite3.connect('app.db') as conn: # Work with database pass# Automatically closed and committed- Use parameterized queries:
cursor.execute('SELECT * FROM users WHERE id = ?', (user_id,)) # Safe- Handle exceptions:
try: conn.execute('INSERT INTO users VALUES (?, ?)', (id, name)) conn.commit()except sqlite3.IntegrityError: print("Duplicate key") conn.rollback()except Exception as e: print(f"Unexpected error: {e}") conn.rollback() raise- Test thoroughly:
# Test suite should coverpytest tests/ -v --cov
# Include integration tests# Include concurrent access tests# Include migration tests- Monitor in production:
conn.enable_monitoring()metrics = conn.get_metrics()# Alert on anomaliesFor more help:
HELIOSDB_SQLITE_DROP_IN_GUIDE.md- Getting startedHELIOSDB_SQLITE_FAQ.md- Common questionsHELIOSDB_SQLITE_ADVANCED_FEATURES.md- Advanced usage- GitHub Issues - Bug reports and discussions