-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Bayer ha scritto:
> Manlio Perillo wrote:
> Hi.
> 
> I would like to use SQL schemas in my projects, however support in
> SQLAlchemy is quite poor.
> 
> What I want to do is to create a custom MetaData object, that allows me
> to specify the default schema name to use.
> 
> All tables bound to that meta data, will be created inside that schema.
> With a DDL listener, I then make sure CREATE SCHEMA and DROP SCHEMA
> statements are issued.
> 
>> does this work for you ?
> 

> [...]

Ok, sorry for the delay.
Following your suggestions I have written this:

http://paste.pocoo.org/show/175512/

What do you think?


When writing this code I found some problems with SQLAlchemy:

1) There is no support for SQL Schema at all.

   It is ok, for me, if there is no direct support for SQL Schema in
   SQLAlchemy, but this is a standard feature, so SQLALchemy dialects
   should:

   * define a `supports_schemas` attribute, as a boolean
   * define a `has_schema` method, to check is a schema exists

   Can I fill a ticket with this feature request?

2) I would like to emulate SQL Schema support in SQLite, using secondary
   databases, attached to the main database.

   However, I noted that SQLAlchemy executes the following query:

     BEGIN
     PRAGMA "test".table_info("test")
     ()
     ROLLBACK

   for a table named "test" in a schema named "test"
   (to be precise, the previous query is exected two times).

   It seems that SQLAlchemy assumes that the schema refers to a
   secondary database.

   The problem is that SQLAlchemy executes these queries **before** my
   DDL listener is called, so the query fails because I don't have yet
   attached the secondary database.


   I think that this behaviour is incorrect.
   The "before-create" listeners of a MetaData object should be called
   before checking if the tables exist.

   Should I fill a bug report?


Thanks  Manlio
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAktwipkACgkQscQJ24LbaUQ7uACggb3Q3kgAQL99XQaqt6lOxSRF
Fx8AnRxjpmtcpSJ8foMhAptKUWxaF6X3
=ZCiM
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to