Description
This is a small project that attempts to seamlessly integrate SQLAlchemy into the Django web framework.
It does this not by attempting to actually replace Django's ORM, but by implementing a Django application that automatically reflects the database and builds the SQLAlchemy ORM objects.
Features
- Automagically creates SQLAlchemy ORM objects
- Introspects Django models to include backreferences
- Able to provide custom SQLAlchemy table, object, and mapper objects.
- Can use Django models as objects for the SQLAlchemy ORM
Mailing List
Documentation
Motivation
Simple. Try getting a query like this out of Django:
SELECT root_source_1.id AS root_source_1_id,
root_source_1.name AS root_source_1_name,
root_source_1.description AS root_source_1_description,
root_source_1.identifier_id AS root_source_1_identifier_id,
root_featuretype_2.id AS root_featuretype_2_id,
root_featuretype_2.name AS root_featuretype_2_name,
root_featuretype_2.display AS root_featuretype_2_display,
root_feature.id AS root_feature_id,
root_feature.source_id AS root_feature_source_id,
root_feature.type_id AS root_feature_type_id,
root_feature.location AS root_feature_location,
root_propertytype_3.id AS root_propertytype_3_id,
root_propertytype_3.name AS root_propertytype_3_name,
root_propertytype_3.display AS root_propertytype_3_display,
root_property_4.id AS root_property_4_id,
root_property_4.feature_id AS root_property_4_feature_id,
root_property_4.type_id AS root_property_4_type_id,
root_property_4.value AS root_property_4_value,
root_property_4.idxfti AS root_property_4_idxfti
FROM (
SELECT DISTINCT
root_feature.id AS root_feature_id,
root_feature.id AS root_feature_oid
FROM root_feature
LEFT OUTER JOIN
root_property ON root_property.feature_id = root_feature.id
LEFT OUTER JOIN
root_propertytype ON root_property.type_id = root_propertytype.id
LEFT OUTER JOIN
root_location ON root_location.feature_id = root_feature.id
LEFT OUTER JOIN
root_modifier ON root_location.start_mod_id = root_modifier.id
LEFT OUTER JOIN
root_location AS root_location_5 ON root_location_5.feature_id = root_feature.id
LEFT OUTER JOIN
root_modifier AS root_modifier_6 ON root_location_5.end_mod_id = root_modifier_6.id
WHERE root_feature.source_id = %(root_feature_source_id)s
AND (
root_location.start + %(root_modifier_multiplier)s * root_modifier_6.multiplier <= %(literal)s
AND root_location."end" + %(root_modifier_multiplier_1)s * root_modifier_6.multiplier >=
%(literal_1)s
OR root_location.start + %(root_modifier_multiplier_2)s * root_modifier_6.multiplier >=
%(literal_2)s
AND root_location.start + %(root_modifier_multiplier_3)s * root_modifier_6.multiplier <=
%(literal_3)s
OR root_location."end" + %(root_modifier_multiplier_4)s * root_modifier_6.multiplier >=
%(literal_4)s
AND root_location."end" + %(root_modifier_multiplier_5)s * root_modifier_6.multiplier <=
%(literal_5)s
)
ORDER BY
root_feature.id
) AS tbl_row_count,
root_feature
LEFT OUTER JOIN
root_source AS root_source_1 ON root_feature.source_id = root_source_1.id
LEFT OUTER JOIN
root_featuretype AS root_featuretype_2 ON root_feature.type_id = root_featuretype_2.id
LEFT OUTER JOIN
root_property AS root_property_4 ON root_property_4.feature_id = root_feature.id
LEFT OUTER JOIN
root_propertytype AS root_propertytype_3 ON root_property_4.type_id = root_propertytype_3.id
WHERE root_feature.id = tbl_row_count.root_feature_id
ORDER BY
root_feature.id,
root_source_1.id,
root_featuretype_2.id,
root_property_4.id,
root_propertytype_3.id
