Thank you Mike and Audrius, this is very helpful. I have  installed  
SQLAlchemy 0.8.0b1 and tried the code Mike gave to me:
Base = declarative_base()

def character_type(length):
    return String(length).with_variant(String(length, 
collation='utf8_general_ci'), 'mysql').with_variant(String(length, 
collation='NOCASE'), 'sqlite')

Atable = Table("atable", Base.metadata,
    Column("name", character_type(200))
    )
 
It works in sqlalchemy, but not in alembic.
after running 'alembic revision --autogenerate', and got migration code:
 
def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.create_table('atable',
    sa.Column('name', sa.*Variant*(length=200), nullable=True),
    sa.PrimaryKeyConstraint()
    )
Surely 'Variant' is strange to me, but I have no idea, then I got 
below after I typed command 'alembic upgrade head':
INFO  [alembic.migration] Context impl MySQLImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.
INFO  [alembic.migration] Running upgrade None -> 1ba36c080bdb
Traceback (most recent call last):
  File "/usr/local/bin/alembic", line 9, in <module>
    load_entry_point('alembic==0.3.6', 'console_scripts', 'alembic')()
  File 
"/usr/local/lib/python2.7/dist-packages/alembic-0.3.6-py2.7.egg/alembic/config.py",
 
line 229, in main
    **dict((k, getattr(options, k)) for k in kwarg)
  File 
"/usr/local/lib/python2.7/dist-packages/alembic-0.3.6-py2.7.egg/alembic/command.py",
 
line 121, in upgrade
    script.run_env()
  File 
"/usr/local/lib/python2.7/dist-packages/alembic-0.3.6-py2.7.egg/alembic/script.py",
 
line 192, in run_env
    util.load_python_file(self.dir, 'env.py')
  File 
"/usr/local/lib/python2.7/dist-packages/alembic-0.3.6-py2.7.egg/alembic/util.py",
 
line 185, in load_python_file
    module = imp.load_source(module_id, path, open(path, 'rb'))
  File "alembic/env.py", line 76, in <module>
    run_migrations_online()
  File "alembic/env.py", line 69, in run_migrations_online
    context.run_migrations()
  File "<string>", line 7, in run_migrations
  File 
"/usr/local/lib/python2.7/dist-packages/alembic-0.3.6-py2.7.egg/alembic/environment.py",
 
line 467, in run_migrations
    self.get_context().run_migrations(**kw)
  File 
"/usr/local/lib/python2.7/dist-packages/alembic-0.3.6-py2.7.egg/alembic/migration.py",
 
line 211, in run_migrations
    change(**kw)
  File "alembic/versions/1ba36c080bdb_.py", line 25, in upgrade
    sa.Column('name', sa.Variant(length=200), nullable=True),
AttributeError: 'module' object has no attribute 'Variant'
 
Did alembic  accept user defined data type? Can I get it to my alembic 
migration script? 
 
Thank you very much for your help!
 

On Friday, December 7, 2012 11:28:01 AM UTC-5, Audrius Kažukauskas wrote:

> On Thu, 2012-12-06 at 17:43:45 -0800, junepeach wrote: 
> > How to upgrade to a newer sqlalchemy version? I can not find a related 
> > document. Should I just use pip to install the current one? Will both 
> > version conflict? 
>
> The answer depends on how and where SA is installed already.  The best 
> way IMHO is to use separate virtualenvs for each of your projects (if 
> you're not doing this already).  Since SQLAlchemy 0.8 is not released 
> yet, you'd need to issue pip (from within virtualenv) as follows: 
>
>   pip install -U -e hg+
> https://bitbucket.org/sqlalchemy/sqlalchemy#egg=SQLAlchemy 
>
> -- 
> Audrius Kažukauskas 
> http://neutrino.lt/ 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/EdMyQ7t_pokJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to