Re: [sqlalchemy] reflecting stored procedure names, enums, and the like

2018-03-10 Thread Mike Bayer
On Fri, Mar 9, 2018 at 11:22 PM, Victor Olex
 wrote:
> Reflecting stored procedure as first class model objects could be very
> useful. I would imagine those objects be Python callable bound to an engine
> or session.

at best, a stored procedure object would be:
StoredProcedure("foobar(x, y, z) BEGIN do  END"), that is, it
would just hold a string with the database-specific DDL.  Stored
procedures are by their nature written imperatively, unlike most of
SQL which is declarative.The whole thing SQLAlchemy and other
database tools do turning SQL into various DSLs is based on the fact
that SQL is declarative.  This would not work at all for an imperative
system like stored procedure languages.



>
>
> On Tuesday, August 16, 2016 at 10:28:25 AM UTC-4, Mike Bayer wrote:
>>
>>
>>
>> On 08/16/2016 03:33 AM, Chris Withers wrote:
>> > Gotcha, would there be any interest in adding StoredProcedure objects?
>>
>> I wouldn't rush to doing that.   it's not clear what these objects would
>> do that DDL() doesn't and also I'd want to address triggers at the same
>> time.  See
>>
>> http://alembic.zzzcomputing.com/en/latest/cookbook.html#replaceable-objects
>> for some of what would be needed.
>> >
>> > For the immediate need of "drop everything", your suggestion sounds like
>> > the best way forward, but I wonder if solving the more generic
>> > "reflecting stored procedures" problem might help with other things...
>>
>> just the names is much simpler.  inspector.get_stored_procedure_names(),
>> much easier add.
>>
>>
>> >
>> > Have any tools emerged for comparing two databases' schemas? I guess the
>> > stuff used to auto-generate migrations must largely solve this problem?
>>
>> alembic's API can be used for that to a partial extent.  there are also
>> some other rough approaches on pypi some of which have SQLAlchemy in
>> there and some do not.
>>
>>
>>
>> >
>> > Sorry, I'm a bit rambly this morning...
>> >
>> >
>> > On 15/08/2016 14:38, Mike Bayer wrote:
>> >>
>> >>
>> >> We should have reflection for PG ENUM in there already.   SP names and
>> >> such, there's no "stored procedure" object, so if you wanted it to
>> >> look like the thing you see here you'd make a StoredProcedure() class
>> >> that's a subclass of DDLElement, etc.  I don't know that there's a
>> >> hook to add new methods to the Inspector() as of yet though.  If
>> >> you're just looking for a "drop everything" method I'd probably forego
>> >> all that boilerplate and just have "drop_pg_sps", "drop_mysql_sps",
>> >> etc. functions and key them off of engine.name in a dictionary or
>> >> something.
>> >>
>> >>
>> >>
>> >> On 08/15/2016 06:16 AM, Chris Withers wrote:
>> >>> Hi All,
>> >>>
>> >>> What's the best way (preferably database agnostic) to reflect stored
>> >>> procedure names, enums names and other non-table-specific items?
>> >>>
>> >>> I'm trying to improve this function, which is based on Mike's original
>> >>> recipe:
>> >>>
>> >>>
>> >>> https://github.com/Mortar/mortar_rdb/blob/eb99d549be02643d4d670db2ee52b93b0c386fb4/mortar_rdb/__init__.py#L134
>> >>>
>> >>>
>> >>>
>> >>> I'd like to expand to to basically delete as much as possible in a
>> >>> database to give a clean starting ground for tests...
>> >>>
>> >>> Chris
>> >>>
>> >>
>> >
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
On Fri, Mar 9,
2018 at 11:22 PM, Victor Olex victor.o...@vtenterprise.com>
wrote:Reflecting stored procedure as first class model objects
could be very useful. I would imagine those objects be Python callable
bound to an engine or session.On Tuesday,
August 16, 2016 at 10:28:25 AM UTC-4, Mike Bayer wrote:

On 08/16/2016 03:33 AM, Chris Withers wrote:
> Gotcha, would there be any interest in adding StoredProcedure objects?

I wouldn't rush to doing that.   it's not clear what these
objects would
do that DDL() doesn't and also I'd want to address triggers at the same
time.  See
http://alembic.zzzcomputing.com/en/latest/cookbook.html#replaceable-objects";
rel="nofollow" target="_blank"
data-saferedirecturl="https://www.google.com/url?hl=en&q=http://alembic.zzzcomputing.com/en/latest/cookbook.html%23replaceable-objects&source=gmail&ust=152078352219&usg=AFQjCNHQlHGB0B-wUezGGd5ZdJknEbVjUw";>http://alembic.zzzcomputing.com/en/latest/cookbook.html#replaceable-objec

Re: [sqlalchemy] reflecting stored procedure names, enums, and the like

2018-03-09 Thread Victor Olex
Reflecting stored procedure as first class model objects could be very 
useful. I would imagine those objects be Python callable bound to an engine 
or session.

On Tuesday, August 16, 2016 at 10:28:25 AM UTC-4, Mike Bayer wrote:
>
>
>
> On 08/16/2016 03:33 AM, Chris Withers wrote: 
> > Gotcha, would there be any interest in adding StoredProcedure objects? 
>
> I wouldn't rush to doing that.   it's not clear what these objects would 
> do that DDL() doesn't and also I'd want to address triggers at the same 
> time.  See 
> http://alembic.zzzcomputing.com/en/latest/cookbook.html#replaceable-objects 
> for some of what would be needed. 
> > 
> > For the immediate need of "drop everything", your suggestion sounds like 
> > the best way forward, but I wonder if solving the more generic 
> > "reflecting stored procedures" problem might help with other things... 
>
> just the names is much simpler.  inspector.get_stored_procedure_names(), 
> much easier add. 
>
>
> > 
> > Have any tools emerged for comparing two databases' schemas? I guess the 
> > stuff used to auto-generate migrations must largely solve this problem? 
>
> alembic's API can be used for that to a partial extent.  there are also 
> some other rough approaches on pypi some of which have SQLAlchemy in 
> there and some do not. 
>
>
>
> > 
> > Sorry, I'm a bit rambly this morning... 
> > 
> > 
> > On 15/08/2016 14:38, Mike Bayer wrote: 
> >> 
> >> 
> >> We should have reflection for PG ENUM in there already.   SP names and 
> >> such, there's no "stored procedure" object, so if you wanted it to 
> >> look like the thing you see here you'd make a StoredProcedure() class 
> >> that's a subclass of DDLElement, etc.  I don't know that there's a 
> >> hook to add new methods to the Inspector() as of yet though.  If 
> >> you're just looking for a "drop everything" method I'd probably forego 
> >> all that boilerplate and just have "drop_pg_sps", "drop_mysql_sps", 
> >> etc. functions and key them off of engine.name in a dictionary or 
> >> something. 
> >> 
> >> 
> >> 
> >> On 08/15/2016 06:16 AM, Chris Withers wrote: 
> >>> Hi All, 
> >>> 
> >>> What's the best way (preferably database agnostic) to reflect stored 
> >>> procedure names, enums names and other non-table-specific items? 
> >>> 
> >>> I'm trying to improve this function, which is based on Mike's original 
> >>> recipe: 
> >>> 
> >>> 
> https://github.com/Mortar/mortar_rdb/blob/eb99d549be02643d4d670db2ee52b93b0c386fb4/mortar_rdb/__init__.py#L134
>  
> >>> 
> >>> 
> >>> 
> >>> I'd like to expand to to basically delete as much as possible in a 
> >>> database to give a clean starting ground for tests... 
> >>> 
> >>> Chris 
> >>> 
> >> 
> > 
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] reflecting stored procedure names, enums, and the like

2016-08-16 Thread Mike Bayer



On 08/16/2016 03:33 AM, Chris Withers wrote:

Gotcha, would there be any interest in adding StoredProcedure objects?


I wouldn't rush to doing that.   it's not clear what these objects would 
do that DDL() doesn't and also I'd want to address triggers at the same 
time.  See 
http://alembic.zzzcomputing.com/en/latest/cookbook.html#replaceable-objects 
for some of what would be needed.


For the immediate need of "drop everything", your suggestion sounds like
the best way forward, but I wonder if solving the more generic
"reflecting stored procedures" problem might help with other things...


just the names is much simpler.  inspector.get_stored_procedure_names(), 
much easier add.





Have any tools emerged for comparing two databases' schemas? I guess the
stuff used to auto-generate migrations must largely solve this problem?


alembic's API can be used for that to a partial extent.  there are also 
some other rough approaches on pypi some of which have SQLAlchemy in 
there and some do not.






Sorry, I'm a bit rambly this morning...


On 15/08/2016 14:38, Mike Bayer wrote:



We should have reflection for PG ENUM in there already.   SP names and
such, there's no "stored procedure" object, so if you wanted it to
look like the thing you see here you'd make a StoredProcedure() class
that's a subclass of DDLElement, etc.  I don't know that there's a
hook to add new methods to the Inspector() as of yet though.  If
you're just looking for a "drop everything" method I'd probably forego
all that boilerplate and just have "drop_pg_sps", "drop_mysql_sps",
etc. functions and key them off of engine.name in a dictionary or
something.



On 08/15/2016 06:16 AM, Chris Withers wrote:

Hi All,

What's the best way (preferably database agnostic) to reflect stored
procedure names, enums names and other non-table-specific items?

I'm trying to improve this function, which is based on Mike's original
recipe:

https://github.com/Mortar/mortar_rdb/blob/eb99d549be02643d4d670db2ee52b93b0c386fb4/mortar_rdb/__init__.py#L134



I'd like to expand to to basically delete as much as possible in a
database to give a clean starting ground for tests...

Chris







--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] reflecting stored procedure names, enums, and the like

2016-08-16 Thread Chris Withers

Gotcha, would there be any interest in adding StoredProcedure objects?

For the immediate need of "drop everything", your suggestion sounds like 
the best way forward, but I wonder if solving the more generic 
"reflecting stored procedures" problem might help with other things...


Have any tools emerged for comparing two databases' schemas? I guess the 
stuff used to auto-generate migrations must largely solve this problem?


Sorry, I'm a bit rambly this morning...


On 15/08/2016 14:38, Mike Bayer wrote:



We should have reflection for PG ENUM in there already.   SP names and 
such, there's no "stored procedure" object, so if you wanted it to 
look like the thing you see here you'd make a StoredProcedure() class 
that's a subclass of DDLElement, etc.  I don't know that there's a 
hook to add new methods to the Inspector() as of yet though.  If 
you're just looking for a "drop everything" method I'd probably forego 
all that boilerplate and just have "drop_pg_sps", "drop_mysql_sps", 
etc. functions and key them off of engine.name in a dictionary or 
something.




On 08/15/2016 06:16 AM, Chris Withers wrote:

Hi All,

What's the best way (preferably database agnostic) to reflect stored
procedure names, enums names and other non-table-specific items?

I'm trying to improve this function, which is based on Mike's original
recipe:

https://github.com/Mortar/mortar_rdb/blob/eb99d549be02643d4d670db2ee52b93b0c386fb4/mortar_rdb/__init__.py#L134 




I'd like to expand to to basically delete as much as possible in a
database to give a clean starting ground for tests...

Chris





--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] reflecting stored procedure names, enums, and the like

2016-08-15 Thread Mike Bayer



We should have reflection for PG ENUM in there already.   SP names and 
such, there's no "stored procedure" object, so if you wanted it to look 
like the thing you see here you'd make a StoredProcedure() class that's 
a subclass of DDLElement, etc.  I don't know that there's a hook to add 
new methods to the Inspector() as of yet though.  If you're just looking 
for a "drop everything" method I'd probably forego all that boilerplate 
and just have "drop_pg_sps", "drop_mysql_sps", etc. functions and key 
them off of engine.name in a dictionary or something.




On 08/15/2016 06:16 AM, Chris Withers wrote:

Hi All,

What's the best way (preferably database agnostic) to reflect stored
procedure names, enums names and other non-table-specific items?

I'm trying to improve this function, which is based on Mike's original
recipe:

https://github.com/Mortar/mortar_rdb/blob/eb99d549be02643d4d670db2ee52b93b0c386fb4/mortar_rdb/__init__.py#L134


I'd like to expand to to basically delete as much as possible in a
database to give a clean starting ground for tests...

Chris



--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


[sqlalchemy] reflecting stored procedure names, enums, and the like

2016-08-15 Thread Chris Withers

Hi All,

What's the best way (preferably database agnostic) to reflect stored 
procedure names, enums names and other non-table-specific items?


I'm trying to improve this function, which is based on Mike's original 
recipe:


https://github.com/Mortar/mortar_rdb/blob/eb99d549be02643d4d670db2ee52b93b0c386fb4/mortar_rdb/__init__.py#L134

I'd like to expand to to basically delete as much as possible in a 
database to give a clean starting ground for tests...


Chris

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.