does your dialect override DDLCompiler.get_column_specification()? That's the best way to get in extra things like NOT NULL, etc. Example: https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/dialects/mysql/base.py#L982


On 03/01/2017 02:13 PM, Alexander Peletz wrote:
I am using the pyhive library which includes a partial implementation of
the 'hive' dialect. I have edited various aspects of this dialect but I
am still unable to affect the initial create table statement that
Alembic is issuing to build the alembic_version table. Here is what
Alembic is issuing:

'CREATE TABLE `alembic_version` (\n\t`version_num` STRING NOT NULL,
\n\tCONSTRAINT `alembic_version_pkc` PRIMARY KEY (`version_num`)\n)\n\n'

And here is what I need:
'CREATE TABLE `alembic_version` (\n\t`version_num` STRING\n)\n\n'

I have attempted to add a visit_primary_key_constraint() method to my
dialect which simply returns '' but this is having no effect. And I am a
bit lost in finding which method I should override to ensure I never
append a 'NOT NULL' string to the end of a column specification.

Any recommendations?

Thanks,
Alexander


On Friday, February 10, 2017 at 1:26:20 PM UTC-5, mike bayer wrote:



    On 02/10/2017 12:41 PM, Alexander Peletz wrote:
    > Great thank you for the quick response! I actually found this morning
    > that I can put the class definition in alembic/ddl/impl.py and it
    works
    > (seemed like a logical module for it?).
    >
    > Next issue is the CREATE TABLE statement used to create the
    > alembic_version table uses keywords that are not valid HiveQL
    keywords.
    > I assume somewhere in the HiveImpl class I could override the
    contents
    > of this statement, but I couldn't figure out where/how to do that.


    for CREATE TABLE assuming you've written a whole SQLAlchemy dialect,
    you'll want to look into your DDLCompiler in the visit_create_table
    method.    This is on the SQLAlchemy side, not Alembic.

    However, usually you don't need to override visit_create_table as a
    whole, I'd imagine you're needing to deal with something special about
    columns, datatypes, or constraints.   There are individual methods that
    deal with those things, I'd take a look at some of the existing
    SQLAlchemy dialects to see how those things get set up.




    >
    >
    > Thanks,
    > Alexander
    >
    > On Friday, February 10, 2017 at 9:45:38 AM UTC-5, mike bayer wrote:
    >
    >
    >
    >     On 02/10/2017 07:41 AM, Alexander Peletz wrote:
    >     > Hello,
    >     >
    >     > I would like to use Alembic to manage my Hive Metastore. I have
    >     > installed, PyHive, SqlAlchemy, and Alembic. I am able to
    create a
    >     > functional engine object using the 'hive' dialect in
    sqlalchemy,
    >     however
    >     > I cannot get Alembic to recognize this dialect. The problem
    >     appears to
    >     > be a lack of a HiveImpl class in the Alembic package. I
    attempted to
    >     > resolve this by creating an alembic/ddl/hive.py module and
    pasting
    >     the
    >     > following code into that module:
    >     >
    >     >
    >     > from .impl import DefaultImpl
    >     >
    >     > class HiveImpl(DefaultImpl):
    >     >     __dialect__ = 'hive'
    >
    >
    >
    >     you don't actually have to create a "hive.py" file.  Anywhere
    in your
    >     hive dialect, simply put the above code that you have (using the
    >     correct
    >     imports of course).  The DefaultImpl uses a metaclass that
    will allow
    >     the "hive" name to be available to alembic as a result of this
    class
    >     being created.
    >
    >
    >     >
    >     >
    >     >
    >     >
    >     > I simply want to be able to execute raw SQL against a Hive
    >     instance (no
    >     > ORM implementation needed) and I was hoping to use Alembic to
    >     manage the
    >     > minimum upgrade/downgrade functionality. Are there any
    simple edits I
    >     > can make to the Alembic source code to allow me to achieve
    this goal?
    >     >
    >     >
    >     >
    >     > Thanks,
    >     >
    >     > Alexander
    >     >
    >     > --
    >     > You received this message because you are subscribed to the
    Google
    >     > Groups "sqlalchemy-alembic" group.
    >     > To unsubscribe from this group and stop receiving emails
    from it,
    >     send
    >     > an email to sqlalchemy-alembic+unsubscr...@googlegroups.com
    <javascript:>
    >     <javascript:>
    >     > <mailto:sqlalchemy-alembic+unsubscr...@googlegroups.com
    <javascript:>
    >     <javascript:>>.
    >     > For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>
    >     <https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>>.
    >
    > --
    > You received this message because you are subscribed to the Google
    > Groups "sqlalchemy-alembic" group.
    > To unsubscribe from this group and stop receiving emails from it,
    send
    > an email to sqlalchemy-alembic+unsubscr...@googlegroups.com
    <javascript:>
    > <mailto:sqlalchemy-alembic+unsubscr...@googlegroups.com
    <javascript:>>.
    > For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.

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

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

Reply via email to