beyond-blockchain/bbc1

When using MySQL, different domains store in same database.

Opened this issue · 4 comments

MysqlAdaptor doesn't create database in each domain.

I tried to fix it, when the database whose name is domain_id doesn't exist, create it.
But there is another problem.

It is recommended that you do not use names that begin with Me or MeN, where M and N are integers.
For example, avoid using 1e as an identifier, because an expression such as 1e+3 is ambiguous.
Depending on context, it might be interpreted as the expression 1e + 3 or as the number 1e+3.

Be careful when using MD5() to produce table names because it can produce names in illegal or ambiguous formats such as those just described.

https://dev.mysql.com/doc/refman/5.6/en/identifiers.html

domain_id is result of MD5 hash function, therefore the head of domain_id collides '1e' probablistically.

It can avoid to surround database name with backticks.
But I cannot be assure that it is the best solution.

quvox commented

Thanks.

To avoid the probrem, I will modify data_handler.py to append a prefix string like "bbc".

quvox commented

Sorry, I answered wrongly.
You can set DB for each domain by modifying config.json.
'db' entry in a target domain specifies what database you uses.

In the current implementation, the name of the database must be configured manually in the config.json. I'm not sure whether it is a good idea to determine the database name automatically (like "dom"+domain_id).