Wow, you don't mess around. Great!
No time to look at this right now (at work) but I'll take a look tonight.
> I intend to make all connections through sqlalchemy; that way, we'll
> be able to count on having sqlalchemy's goodies available to see the
> metadata, etc. Right now, though, I can't make SYS AS SYSDBA, SYS AS
> SYSOPER, etc. connections to Oracle through sqlalchemy.create_engine.
> For cx_Oracle.connect (the past method), you can pass a `mode`
> argument with values of 0, cx_Oracle.SYSDBA (2), cx_Oracle.SYSOPER
> (4). sqlalchemy.get_engine cries "invalid arguments" when I try to
> pass it `mode=modeval`, though.
Have you seen this:
http://www.sqlalchemy.org/docs/05/reference/dialects/oracle.html
The docs indicate can append "?mode=modeval@ onto the end of the URL
rather than passing an extra arg to create_engine. Is this what you were
doing?
Menno
Have you seen this:
http://www.sqlalchemy.org/docs/05/reference/dialects/oracle.html
The docs indicate can append "?mode=modeval@ onto the end of the URL
rather than passing an extra arg to create_engine. Is this what you were
doing?
Connecting with create_engine() uses the standard URL approach of oracle://user:pass@host:port/dbname[?key=value&key=value...]. If dbname is present, the host, port, and dbname tokens are converted to a TNS name using the cx_oracle makedsn() function. Otherwise, the host token is taken directly as a TNS name.
Additional arguments which may be specified either as query string arguments on the URL, or as keyword arguments to create_engine() are:
I'd give that a try, they're still sprinting today. :)
Take care,
-Brian
Looking at _parse_rfc1738_args() it seems like a URL like
"oracle://sys:syspassword@/orcl?mode=2" would work.
The difference is the extra / after the @.
Can't test it at work though...
Menno
Great!
> Offhand, the only SQLA goodie I see is get_tables(), and even that
> isn't so useful because our `ls` is good for all sorts of objects -
> tables, views, stored procedures, indexes, etc etc etc so get_tables
> alone can't replace it. But I haven't even begun to probe into what
> SQLAlchemy has got.
Good point. I don't know how well it handles views and indexes and I bet
it has nothing for stored procedures. Let's see what's in there before
giving up on it completely.
The person at the back of the room in the open spaces session seemed to
think that there was a bunch of recently added metadata support. Hunting
around a bit I found reference to Randall Smith, who's supposedly
working on this:
http://www.mail-archive.com/sqlal...@googlegroups.com/msg12686.html
Looks like this gives support for schemas, tables, views, keys and
indices. Not sure if the work has made it into the SQLA trunk.
Hunting around a bit further I found Gerald:
http://www.mail-archive.com/sqlal...@googlegroups.com/msg12686.html
It has an an API for inspecting the schema of Oracle, Postgres and MySQL
DBs and can handle schemas, tables, views, triggers, sequences and
stored procedures. Probably also worth a look.
> I wonder... if we ended up having to build a bunch of
> database-specific metadata access objects after all, whether SQLA
> would be interested in porting them up? That would make our work even
> more widely useful. Maybe we should try to write them with that
> possibility in mind.
DB specific metadata interfaces would also help isolating requirements
for specific DB API modules. Currently sqlpython requires that you have
cx_Oracle installed even if you don't intend to use Oracle because it is
imported and used all over the place. Moving all DB specific
functionality separate modules/classes would mean you only need to
install the DB API modules for the DBs you actually use. The import of
cx_Oracle/psycopg/whatever could be delayed until a connection to such a
DB is requested.
Menno
Hunting
around a bit I found reference to Randall Smith, who's supposedly
working on this:
http://www.mail-archive.com/sqlal...@googlegroups.com/msg12686.html
Looks like this gives support for schemas, tables, views, keys and
indices. Not sure if the work has made it into the SQLA trunk.
Hunting around a bit further I found Gerald:
http://www.mail-archive.com/sqlal...@googlegroups.com/msg12686.html
It has an an API for inspecting the schema of Oracle, Postgres and MySQL
DBs and can handle schemas, tables, views, triggers, sequences and
stored procedures. Probably also worth a look.
DB specific metadata interfaces would also help isolating requirements
for specific DB API modules. Currently sqlpython requires that you have
cx_Oracle installed even if you don't intend to use Oracle because it is
imported and used all over the place. Moving all DB specific
functionality separate modules/classes would mean you only need to
install the DB API modules for the DBs you actually use. The import of
cx_Oracle/psycopg/whatever could be delayed until a connection to such a
DB is requested.
Good news! I got hold of Andy Todd, author of Gerald, and he agreed
to begin releasing eggs on PyPI beginning with Gerald 0.2.5 in a few
days. So that takes care of the dependency issue; I think we can do
some very serious experimentation with Gerald now. If it goes well,
let's use it, and eventually contribute mssqlite_schema.py and
sqlite_schema.py back to Gerald.
OK, thanks for that. In general I'm happy to accept suggestions for
improvement and I don't think that anything you have suggested will
'break' Gerald so I propose to incorporate as many of your suggestions
as possible. One question at a time:
1. Internal representation.
The internal storage (and thus metadata model) is a mess. It has evolved
in a very unstructured way and I have a task in my to do list to fix it
all up. I'll happily move that up the list to be priority number 1.
Given the amount of changes that will require (and the fact that it will
break any existing code) I think that this needs to be done carefully.
So my plan is;
- Document the object model that will be used (preferably on a wiki -
any suggestions anyone?)
- Update each of the *schema.py files and their test suites
- Test, test, test
- Release
If I/we get the first part right the rest should be a relative breeze ;-)
2. My schema vs. all available objects
Conceptually this is quite a simple change for every database *apart*
from Oracle. Even then it is entirely possible. I've just never seen the
need for it. I'm happy to do this - probably with a flag of some sort to
differentiate between 'my' objects and 'public' objects. Suggestions for
how to work this into the current API are more than welcome.
3. License.
I am happy to relicense Gerald to the MIT license if that makes life
easier. To my (IANAL) mind there isn't a huge difference between them
and changing will not cause me any problems.
4. Access to the code.
I can grant anyone who asks (nicely) access to the SVN repository at
SourceForge to generate and apply patches.
Alternatively, I have been toying with the idea of moving to a DVCS and
to that end I have created an account at Bitbucket. That is as far as I
have got though. If someone would like to volunteer to help me port
between Subversion and Hg I am happy to move the project repository to
Bitbucket as that will more easily support some of the changes we are
discussing here.
Regards,
Andy
--
From the desk of Andrew J Todd esq - http://www.halfcooked.com/
In your API at
http://groups.google.com/group/sqlpython/web/gerald-api?hl=en&pli=1
you're specifying columns, indexes, etc. as tuples. That would work
fine, though I was going to suggest dicts, both to make it a little
bit self-documenting and to ease the burden of standardizing: then, if
it turns out that there's another important piece of data to include
about (say) a mssql column, mssql_schema.py can simply include that in
its column dicts and not worry about inserting a new null element into
the column elements for all the other rdbms's. (It would be the
responsibility of examining programs, like sqlpython, not to die
gruesomely if they don't find a key they expected.)
(It doesn't remove all the standardization burden, of course - there
still needs to be a standard set of key names)
I'm attaching modified versions of oracle_schema.py and
postgres_schema.py as examples of outputting dicts - it seemed faster
than writing out what I'm thinking. (`kdiff3` or `meld` or something
vs. your current) Those are all the changes it would take for
sqlpython's metadata queries to work. (Well, and corresponding
changes in mysql_schema.py, of course.)
... but overall, I'm just happy for anything standard we can work
against! Any API is a good API once it's *the* API.
I've got sqlpython talks coming up on Friday (eek!) and the following
Thursday, so I'd better stop trying to get fully-fledged multi-RDBMS
in the next, um, 48 hours :) and instead release sqlpython 1.6.5 -
just one more new bug to fix, probably later today. It'll leave out
all the Gerald-based stuff that's currently in the trunk.
On Mon, Apr 27, 2009 at 8:03 PM, Andy Todd <and...@halfcooked.com> wrote:
> 1. Internal representation.
>
> The internal storage (and thus metadata model) is a mess. It has evolved
> in a very unstructured way and I have a task in my to do list to fix it
> all up. I'll happily move that up the list to be priority number 1.
Thank you! Though I can see where there's really been no reason for,
say, tables and views to report consistently when schema comparison
was the only purpose. "You're comparing a table against a view?
Well, of course they're different!"
> 2. My schema vs. all available objects
>
> Conceptually this is quite a simple change for every database *apart*
> from Oracle. Even then it is entirely possible. I've just never seen the
> need for it. I'm happy to do this - probably with a flag of some sort to
> differentiate between 'my' objects and 'public' objects. Suggestions for
> how to work this into the current API are more than welcome.
Hmmmmmmm
> 3. License.
>
> I am happy to relicense Gerald to the MIT license if that makes life
> easier. To my (IANAL) mind there isn't a huge difference between them
> and changing will not cause me any problems.
True, MIT and BSD are very close. But anyway, it would only be
relevant if we were going to incorporate a fork - as long as Gerald
remains an independent import, there's no need.
> 4. Access to the code.
>
> I can grant anyone who asks (nicely) access to the SVN repository at
> SourceForge to generate and apply patches.
>
> Alternatively, I have been toying with the idea of moving to a DVCS and
> to that end I have created an account at Bitbucket. That is as far as I
> have got though. If someone would like to volunteer to help me port
> between Subversion and Hg I am happy to move the project repository to
> Bitbucket as that will more easily support some of the changes we are
> discussing here.
Nothing wrong with you remaining the gateway, either, as long as you
don't resent the burden, and it doesn't sound like you do. Again,
thanks so much!
--
- Catherine
http://catherinedevlin.blogspot.com/
*** PyOhio * July 25-26, 2009 * pyohio.org ***
Oops! I forgot that the files I sent depend on a tiny function I'd
added in schema.py:
def dict_from_row(curs, row):
return dict(zip((d[0].lower() for d in curs.description), row))
THANK YOU, Andy!
In your API at
http://groups.google.com/group/sqlpython/web/gerald-api?hl=en&pli=1
you're specifying columns, indexes, etc. as tuples. That would work
fine, though I was going to suggest dicts,