For case insensitive columns:
MySQL - use utf8_general_ci
SQLite - use NOCASE collation
....
Can migration tool handle that for most databases or it should be better done in application code?
Thanks and best regards,--
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/-/cgxdiM7P4yMJ.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
--
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/-/JvxaQU8BifsJ.
JP
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()
)
--
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 view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/189ndo8qN6gJ.
SHOW CREATE TABLE gave something back to me:
utf8_general_ci is default collation rule in charset utf8.
mysql> CREATE TABLE t1(col1 CHAR(10) COLLATE utf8_unicode_ci)CHARACTER SET latin1 COLLATE latin1_bin;
Query OK, 0 rows affected (0.01 sec)
mysql> show create table t1;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1 | CREATE TABLE `t1` (
`col1` char(10) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_bin |
mysql> CREATE TABLE t2
-> (
-> col1 CHAR(10) COLLATE utf8_general_ci
-> ) CHARACTER SET latin1 COLLATE latin1_bin;
Query OK, 0 rows affected (0.01 sec)
mysql> show create table t2;
+-------+---------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------------------------------------------------+
| t2 | CREATE TABLE `t2` (
`col1` char(10) CHARACTER SET utf8 DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin |
+-------+---------------------------------------------------------------------------------------------------------------------------------+