Hello, I want my code to be able to switch in runtime between mysql_db and 
sqlite_db. It will get that info from a command line arg. but when I import 
both, I get a conflict of types. I found a half-solution. it can work with when 
blocks, and changing just a const in the code, or I can split the consts to 
different files, and compile a few binaries, each targeting a different db 
backend. But all of this is less than what I hoped for.

The problem is shown concisely here. Cannot refactor code here. 
    
    
    import db_mysql
    import db_sqlite
    
    var db : ___.DbConn
    if input=="mysql":
      db = db_mysql.open("localhost", user, pass, "dbName")
      let ok = db.setEncoding("utf8")
    else:
      db = db_sqlite.open(dbfile, "", "", "")
    
    
    start(db)
    
    
    Run

if I do something like this: 
    
    
     start_processing(db: db_sqlite.DbConn | db_mysql.DbConn)
    
    Run

I will get ambiguity errors later on. (Which type did you mean, to take 
fast_rows from.) 

Reply via email to