postgresql - map multiple value to one in a dict python -


i want move data postgres bigquery.

for can query postgres table schema, map data types.

lookup = {     'char': 'string',     'character': 'string',     'varchar': 'string',     'character varying': 'string',     'text': 'string'} 

my question is, can in such way can provide list(or tuple of values correspond string.

something like, @ psueudocode level:

lookup = {       lambda x: if x in ['char', 'character' ... ] : 'string' else if x in ['int'] : 'integer' else none } 

that return data type

lookup['char'] > string 

while agree comments asking why?, can if think nicer, , it's not hard read:

>>> collections import defaultdict >>> lookup = defaultdict(lambda: 'string', int='integer') >>> lookup['int'] 'integer' >>> lookup['char'] 'string' >>> lookup['varchar'] 'string' 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -