afimb / gtfslib-python

An open source library in python for reading GTFS files and computing various stats and indicators about Public Transport networks
GNU General Public License v3.0
44 stars 6 forks source link

support for destination schema #42

Closed ivanmobigis closed 8 years ago

ivanmobigis commented 8 years ago

Hello,

I'd like to specify which (postgres) schema the data should be loaded to. by default it goes to public, because it is never specified. By changing orm.py thusly:

_metadata = MetaData() to: _metadata = MetaData(schema='myschema')

everything works fine.

the problem is that the way that orm.py is structured passing this as a param requires me to move all the code into a function, it is currently in the init block.

is there a better way to do this ? i tried setting the search path on the _session variable which works for selects but the tables still get created in public.

if there is no better way i can submit a PR for our change.

thanks

-i

laurentg commented 8 years ago

@ivanmobigis I added the support for configurable schema, you can see if that fits the bill for you. I made minimal testing on my side but this seems to work, at least to load the data. I guess the impact on data access should be minimal, but you may better test. Note: there is no unit-test for this.

ivanmobigis commented 8 years ago

Great !

Thanks heaps for your reactivity !!

-ivan