Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    dubiousjim
    @dubiousjim
    You could instead use https://doc.rust-lang.org/std/process/struct.Command.html to interact with the sqlite3 shell/cli.
    jamespeterschinner
    @jamespeterschinner
    Oh perfect! thanks, excuse my ignorance.
    Thom Chiovoloni
    @thomcc
    I'm not really around, but you probably could do the same thing with the csvtab stuff in rusqlite
    Justin Wood
    @ankhers
    Is there some preferred way to deal with migrations with rusqlite?
    Thom Chiovoloni
    @thomcc
    nope, totally up to you. rusqlite is not an opinionated library like that
    Midas Lambrichts
    @MidasLamb
    image.png
    I just ran into this issue when trying to add the preupdate_hook and using it already in my code:
    It is a stacktrace with gdb, according to that line number it's in the "text" part of ValueRef, but somehow it's still a nullpointer it seems?
    Thom Chiovoloni
    @thomcc
    you're probably better off asking on the issue, I'm the only rusqlite member that comes here and I dont have time to help you debug it, unfortunately (also gwenn knows much more about the hooks than i do)
    Midas Lambrichts
    @MidasLamb
    Ok, thanks for the quick response!
    Alexander Samoylenko
    @lxmnk
    Hello! I would like to run SELECT * FROM notes WHERE id IN (?1) (?1 is a Vec<i32>). Could you provide me example, how to pass vector to parameters? I've searched docs and issues, but found examples only for inserting/updating rows.
    Thom Chiovoloni
    @thomcc
    In general SQLite doesn't work like that, but there are workarounds, see rusqlite/rusqlite#430 for a discussion of using the array feature
    but note that using that requires loading the module first
    Alexander Samoylenko
    @lxmnk

    In general SQLite doesn't work like that, but there are workarounds, see rusqlite/rusqlite#430 for a discussion of using the array feature

    Thank you! Just now I've discovered, that I also can generate a SQL string with right placeholders number (?1, ?2). Could you explain, why using array feature is a better choice?

    Thom Chiovoloni
    @thomcc
    I'd probably generate the string
    Alexander Samoylenko
    @lxmnk
    Thank you again)
    Thom Chiovoloni
    @thomcc
    Alexander Samoylenko
    @lxmnk

    I wrote https://github.com/mozilla/application-services/blob/main/components/support/sql/src/repeat.rs for this purpose once upon a time

    I'll check it out, thanks!

    Thom Chiovoloni
    @thomcc
    @lxmnk oh, note that there's a maximum number of parameters that you can pass to SQLite at once. The maximum number is likely either 999 (for versions older than 3.32, e.g. released before 2020-05-22) or 32766 for ones after that. so, you may need to chunk
    you can query it with https://docs.rs/rusqlite/0.24.2/rusqlite/limits/enum.Limit.html#variant.SQLITE_LIMIT_VARIABLE_NUMBER (which requires the limits feature to be on)
    Cédric Bellegarde
    @gnumdk_gitlab
    Hello
    Looking at previous comments, I'm not sure about my question
    I have a built SQL request with random parameters: one string, one vec<i32> and one vec<string>. Will I be able to generate params with array feature?
    Cédric Bellegarde
    @gnumdk_gitlab
    Another question, Is there an equivalent of https://www.kite.com/python/docs/sqlite3.Connection.create_function in ruqlite ?
    Thom Chiovoloni
    @thomcc
    yes: https://docs.rs/rusqlite/0.24.2/rusqlite/struct.Connection.html#method.create_scalar_function (also create_aggregate_function or create_window_function for different kinds of functions — i don't think these have equivalents in the python binding though)
    you need to turn on the functions feature
    Cédric Bellegarde
    @gnumdk_gitlab
    Ok, thanks
    Cédric Bellegarde
    @gnumdk_gitlab
    Looking at the documentation, I understand that this function are only available on query result.
    Thom Chiovoloni
    @thomcc
    hm?
    thats not really true
    what context do you want to use it in?
    Cédric Bellegarde
    @gnumdk_gitlab
    Python allows to do something like this: SELECT * FROM table WHERE myfunction(column)='value'
    Thom Chiovoloni
    @thomcc
    yes that definitely is allowed here
    Cédric Bellegarde
    @gnumdk_gitlab
    ok
    Thom Chiovoloni
    @thomcc
    what part of the documentation makes you think that wouldnt be
    perhaps the docs should be improved
    Cédric Bellegarde
    @gnumdk_gitlab
    English is not my language, so maybe a confusion around the word scalar, will try to implement, if there is really something confusing, will report the an issue
    Thom Chiovoloni
    @thomcc
    oh
    scalar just means the function takes 1 argument
    err
    one rows worth
    aggregate functions are like SUM(...)
    which take many rows as arguments
    Cédric Bellegarde
    @gnumdk_gitlab
    Thanks, so it's me :D
    Thom Chiovoloni
    @thomcc
    and window functions are... weirder: https://sqlite.org/windowfunctions.html
    scalar functions are normal sqlite functions. i dont think the python bindings expose any way to define non-scalar functions, so it doesnt bother distinguishing
    Justin Wood
    @ankhers
    I am trying to use rusqlite::named_params! macro, but I am getting an error with compiling saying "the trait ToSql is not implemented for (&str, &dyn ToSql)", am I supposed to enable a feature for this?
    Thom Chiovoloni
    @thomcc
    can you file a bug?
    that sounds wrong but helping in a github issue seems easier