Skip to first unread message

martjan dedi

unread,
Oct 5, 2016, 10:58:47 AM10/5/16
to Tethys Platform
Hi Guys 

Anyone can help me on how to save my 'geometry' geojson edits in a database PostgreSQL using SQL Alchemy and geoalchemy2 plz.
Any guide to the python code that i should use , any reference video or book it would be very helpful.I tried to create a python function myself as its shown below but it doesen't work.
At list someone tell me where to put my python code(and where to start a session with database)  in app.py in controllers.py in initstores.py or in model.py  . ????
Should i convert my geojson object into a format for the database example wkt or smthing else(what is the function to do that) ???

Best Regards


# def save(first_time):
    
    
#     SpatialBase.metadata.create_all(spatial_engine)

    
#     if first_time:
        
#         session = SpatialSessionMaker()

        
#         gage1 = SpatialStreamGage(geometry)


#         session.add(gage1)


#         session.commit(gage1)
#         session.close()

#     return render(request)

swainn

unread,
Oct 11, 2016, 12:57:42 PM10/11/16
to Tethys Platform
Martjan,

I apologize for the delay in response. I'm working up an example application to illustrate my answer. But in the mean time, I would recommend you take a look at this video tutorial:


The source code for the resulting app can be found here: https://github.com/tethysplatform/tethysapp-postgis_app

This video tutorial illustrates how to work with postgis databases using SQLAlchemy and GeoAlchemy.

NOTE: This app was developed for Tethys version 1.1.0 or 1.2.0, so it may be incompatible with the current release 1.3.0. I'm going to try to update it as I develop the example.
Reply all
Reply to author
Forward
0 new messages