It's my first day using Nim. It looks great from my Python perspective, but I'm 
stuck and finding it difficult to perform a simple database query.

I installed Nim with `brew install nim` ('m using a macbook M1). The 
hello-world app built and ran just fine.

I want to execute a simple SELECT statement on a PostgreSQL database and loop 
through the results to print each row. Can anyone guide me or explain how to do 
this?

I've tried using the db_postgres and db packages, but they didn't work. Now, 
the db_connector package has successfully compiled.
    
    
    import db_connector/db_postgres
    import strformat
    
    proc main() =
      let db = open("localhost:5432", "user**", "pwd**", "db**")
      let query = sql"SELECT key, value, description FROM config;"
      
      for row in db.fastRows(query):
        echo row
      
      db.close()
    
    main()
    
    
    Run

but I've got a compile warning:
    
    
    ld: warning: ignoring duplicate libraries: '-lm'
    
    
    Run

Reply via email to