Re: [web2py] Setting mysql collation in web2py?

2012-01-25 Thread Bruno Rocha
Maybe it should be a parameter with defaults to utf8

On Wed, Jan 25, 2012 at 8:03 PM, mdorval  wrote:

> I've tracked down this problem to this code in DAL create_table:
>
> if self.dbengine == 'mysql':
> if not hasattr(table, "_primarykey"):
> fields.append('PRIMARY KEY(%s)' % table._id.name)
> other = ' ENGINE=InnoDB CHARACTER SET utf8;'
>
> hard coding the character set in the create statement causes all tables
> created to be utf8's default collation utf8_general_ci, regardless of any
> settings set on the database or individual schemas. Can this line be
> removed?
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]


Re: [web2py] Setting mysql collation in web2py?

2012-01-25 Thread mdorval
I've tracked down this problem to this code in DAL create_table:

if self.dbengine == 'mysql':
if not hasattr(table, "_primarykey"):
fields.append('PRIMARY KEY(%s)' % table._id.name)
other = ' ENGINE=InnoDB CHARACTER SET utf8;'

hard coding the character set in the create statement causes all tables 
created to be utf8's default collation utf8_general_ci, regardless of any 
settings set on the database or individual schemas. Can this line be 
removed?


Re: [web2py] Setting mysql collation in web2py?

2012-01-19 Thread mdorval
Thanks for the note! I've tried passing to the driver_args a Charset object 
(defined by the pymysql lib like so):
from gluon.contrib.pymysql import charset
passing into DAL

DAL(,driver_args={'charset':charset.charset_by_id(83))

in the charset module this is the Charset object I'm referring to:
_charsets.add(Charset(83, 'utf8', 'utf8_bin', ''))

but passing in that charset doesn't appear to be anything, as the table is 
still created as the default utf8 collation, utf8_general_ci. In fact, I 
don't see any reference in the pymysql code (or even web2py for that 
matter) that involves actually setting the collation, which leaves me 
baffled as to why the charset module exists in the first place.

The db_codec doesn't appear to help either, because it doesn't seem to 
recognize utf8_bin.

I might be delving a little too deep here for something that web2py simply 
can't do...

Thanks!


Re: [web2py] Setting mysql collation in web2py?

2012-01-19 Thread Bruno Rocha
BTW, DAL receives another argument

driver_args = None

You can pass args to the mysql driver


Re: [web2py] Setting mysql collation in web2py?

2012-01-19 Thread Bruno Rocha
may be this argument

db = DAL("mysql://", * db_codec*='UTF-8')


On Thu, Jan 19, 2012 at 6:47 PM, mdorval  wrote:

> Hey,
> I was wondering if there's any way to set the collation of the mysql
> tables created by web2py to utf8_bin. Thanks!
>



-- 

Bruno Rocha
[http://rochacbruno.com.br]