diff --git a/README.md b/README.md index 745977f..e02cdac 100644 --- a/README.md +++ b/README.md @@ -126,25 +126,41 @@ split_features = split_by_sql( - The db parameter can be a connection string to start a new connection. - Or an existing database connection can be reused. -- To do this, the psycopg2 driver connection needs to be passed: +- To do this, either the psycopg2 connection, or a SQLAlchemy Session + must be passed: SQLAlchemy example: ```python from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker +from fmtm_splitter.splitter import split_by_sql # Creates a SQLAlchemy Session object engine = create_engine("postgresql://postgres:postgres@localhost/postgres") SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) db = SessionLocal() -psycopg2_connection = db.connection() - # Then pass this object as the db param split_features = split_by_sql( aoi, - psycopg2_connection, + db, + num_buildings=50, + osm_extract=osm_extracts, +) +``` + +psycopg2 example: + +```python +import psycopg2 +from fmtm_splitter.splitter import split_by_sql + +db = psycopg2.connect("postgresql://postgres:postgres@localhost/postgres") + +split_features = split_by_sql( + aoi, + db, num_buildings=50, osm_extract=osm_extracts, )