Is ARRAY supported in MySQL?

1,552 views
Skip to first unread message

sqlalchemy_mysql

unread,
Oct 19, 2017, 6:38:59 PM10/19/17
to sqlalchemy
Sorry I don't see any references in doc. I tried using array type but got this error 

can't render element of type <class 'sqlalchemy.sql.sqltypes.ARRAY'>

Compiler <sqlalchemy.dialects.mysql.base.MySQLTypeCompiler object at 0x110949e90> can't render element of type <class 'sqlalchemy.sql.sqltypes.ARRAY'>

Here is my column defintion

sqla.Column(sqla_types.ARRAY(sqla_types.String), default=[], nullable=False)

Mike Bayer

unread,
Oct 20, 2017, 1:25:33 PM10/20/17
to sqlal...@googlegroups.com
to my knowledge, MySQL has no ARRAY datatype available so this would
not work (a google search just now also doesn't turn up anything new).
If either MySQL or MariaDB implements ARRAY, SQLAlchemy's dialect
would require enhancements in order for this to be supported.


>
> --
> 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+...@googlegroups.com.
> To post to this group, send email to sqlal...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

sqlalchemy_mysql

unread,
Oct 20, 2017, 1:35:46 PM10/20/17
to sqlalchemy
That's correct. MySQL doesn't support. I see people workaround by serializing it to string/text and store and retrieve so was wondering SQLAlchemy has some support like that. Seems like NO.

Mike Bayer

unread,
Oct 20, 2017, 2:05:09 PM10/20/17
to sqlal...@googlegroups.com
On Fri, Oct 20, 2017 at 1:35 PM, sqlalchemy_mysql <anv...@gmail.com> wrote:
> That's correct. MySQL doesn't support. I see people workaround by
> serializing it to string/text and store and retrieve so was wondering
> SQLAlchemy has some support like that. Seems like NO.

You use a TypeDecorator for that kind of thing:

http://docs.sqlalchemy.org/en/latest/core/custom_types.html?highlight=typedecorator#typedecorator-recipes
Reply all
Reply to author
Forward
0 new messages