Registry / database / sqlalchemy-solr

sqlalchemy-solr

JSON →
library0.2.4.3pypypi✓ verified 85d ago

Apache Solr dialect for SQLAlchemy, allowing Solr to be queried using SQLAlchemy ORM and Core. Current version 0.2.4.3, supports Python >=3.8 and Solr 6.x-9.x. Release cadence is irregular.

pip install sqlalchemy-solr
INSTALL
IMPORT
SIG · SQLALCHEMY-SOLR
S
sqlalchemy-solr
databasepythonv0.2.4.3
Install
4.4s avg
Import
538ms
Disk
39MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.4.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.560s · 42.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 4.4s · import 0.516s · 38MB
39MB installed
● package 39MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

create_engine
from sqlalchemy import create_engine
from sqlalchemy_solr import create_engine
create_engine is from SQLAlchemy, not sqlalchemy-solr. The dialect is registered via URL prefix.
savoir
from sqlalchemy_solr import savoir
Utility to check Solr version compatibility.

Connect to a Solr core and run a basic SQL query.

from sqlalchemy import create_engine, text import os # Solr URL, default 'http://localhost:8983/solr' solr_url = os.environ.get('SOLR_URL', 'http://localhost:8983/solr') # Create engine with solr:// prefix, database name is Solr core/collection engine = create_engine(f'solr://admin:@localhost:8983/solr/collection1') with engine.connect() as conn: result = conn.execute(text("SELECT * FROM collection1 LIMIT 10")) for row in result: print(row)
Debug
Known issues
gotchaEngine URL must use 'solr://' prefix. The username and password are for HTTP basic auth, not Solr authentication. Database name is the Solr core/collection name.
fix
Use URL format: solr://username:password@host:port/solr/core_name
affects: all
deprecatedPython 3.8 support is the minimum; Python 3.7 and earlier will not work.
fix
Upgrade Python to 3.8+.
affects: >=0.2.4.0
gotchaSQL compilation cache is disabled by default for Solr <9.0. This may impact performance.
fix
If using Solr >=9.0, enable cache by setting environment variable SQLALCHEMY_SOLR_CACHE=1 before engine creation.
affects: >=0.2.4.2
breakingFrom version 0.2.4.0, the dialect returns native Python types instead of strings. Code relying on string results may break.
fix
Update code to handle int/float/datetime values directly.
affects: >=0.2.4.0
Errors
Common errors & fixes
sqlalchemy.exc.ArgumentError: Could not determine version of SQLAlchemy
Missing or incompatible SQLAlchemy version (e.g., 2.x).
fix
Install SQLAlchemy 1.4.x: pip install 'sqlalchemy>=1.4,<2.0'
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8983): Max retries exceeded
Solr server not running or port incorrect.
fix
Start Solr or check host/port in connection string.
ImportError: cannot import name 'savoir' from 'sqlalchemy_solr'
Older version of sqlalchemy-solr without savoir module.
fix
Upgrade to >=0.2.4.0: pip install --upgrade sqlalchemy-solr
solr.exceptions.SolrException: Error from Solr: org.apache.solr.common.SolrException: Collection not found: mycore
Specified Solr core/collection does not exist.
fix
Use existing core name as database in URL.
Upgrade
Version history
0.2.4.3latest on PyPI · released Aug 8, 2024
Audit
Dependencies
sqlalchemy>=1.4,<2.0requiredRequired - integrates with SQLAlchemy Core/ORM
requests>=2.25.1,<3.0requiredRequired - HTTP client for Solr
lxml>=4.0,<6.0requiredRequired - XML parsing for Solr responses
Agent activity
33 hits · last 30 days
node
26
Meta
2
OpenAI (training)
1
Resources
sqlalchemy-solr — pip install sqlalchemy-solr · libregistry