I tested it and simple connection works fine via python more advanced usage 
with nim needs consideration of how to pass strings from nim to duckdb so that 
thet appear single quoted after being passed through nimpy.

pip install duckdb==0.2.3 nimble install nimpy

nimduck.nim
    
    
    import nimpy
    
    let duckdb = pyImport("duckdb")
    let os = pyImport("os")
    
    let conn = duckdb.connect()
    let cursor = conn.cursor()
    
    discard conn.execute("CREATE TABLE test_table (i INTEGER, j STRING)")
    # add some data
    discard conn.execute("""INSERT INTO test_table VALUES (1, 'one')""")
    discard conn.execute("""INSERT INTO test_table VALUES (1, 'two')""")
    discard conn.execute("""INSERT INTO test_table VALUES (1, 'three')""")
    discard conn.execute("""INSERT INTO test_table VALUES (1, 'four')""")
    # as pandas df
    echo (conn.execute("SELECT * FROM test_table").fetchdf())
    echo()
    echo()
    # as numpy array
    echo (conn.execute("SELECT * FROM test_table").fetchnumpy())
    
    
    Run

I have done a similar approach with Firebird3.0 server and their latest python 
firebird driver , which now works nicely for simple queries. Firebird can also 
work as embedded server and packs much more power than sqlite3.

<https://github.com/qqtop/nimfdb>

Reply via email to