zserio
zserio copied to clipboard
Python: Consider to at name definition not only as consts, but as structure
Especially for databases the database and the table names are defined at the end of the python file as constant values:
Example:
package my.database;
sql_database MyDatabase
{
MyTable myTable;
};
sql_table MyTable {
uint8 key;
string name;
bool thirdColumn;
};
Now:
This will generate some files and in the my_database.ph the last part is:
DATABASE_NAME = "MyDatabase"
TABLE_NAME_MY_TABLE = "myTable"
Should be:
It would be very useful if this would be defined maybe as:
DATABASE_STRUCTURE = {
'DATABASE_NAME': "MyDatabase",
'TABLE_NAMES': ["myTable"]
}
This would be certainly very useful for other definitions liketables etc., too.
Then it would be possible at the end to have:
DATABASE_STRUCTURE = {
'DATABASE_NAME': "MyDatabase",
'TABLE_NAMES': {
"myTable" : {
'TABLE_TYPE': "MyTable"
'COLUMN_NAMES': ["key", "name", "thridColumn"],
'COLUMN_TYPES': ['unit8', 'string', 'bool']
},
}
Guess leaving in the const definition for compatibility reasons would be okay.
Thanks for good idea. We can do it.
However, due to urgent new huge development (packed arrays), I am putting this issue to the backlog for now.