GithubHelp home page GithubHelp logo

Comments (5)

vrischmann avatar vrischmann commented on September 15, 2024 1

This is wrong:

  // Create database object
        var db = try sqlite.Db.init(.{
            .mode = sqlite.Db.Mode{ .File = db_path },
            .open_flags = .{
                .write = true,
                .create = true,
            },
            .threading_mode = .MultiThread,
        });

        return .{ .db = &db, .files = &files, .next_id = next_id };

db is stack allocated and invalid after you return. You can either pass the db object around (the value, not a pointer) or you need to restructure your code to make sure the db object outlives anything that keeps a pointer to it.

from zig-sqlite.

margual56 avatar margual56 commented on September 15, 2024

Forgot to mention that the program already runs a query before that to create the table, and that query runs just fine. The issue seems to be with the insert...

from zig-sqlite.

margual56 avatar margual56 commented on September 15, 2024

The issue seems to be with passing around a reference to the database... Why would this be an issue? Isn't there a better way to do this than to initialize the database every time the function is called?

from zig-sqlite.

margual56 avatar margual56 commented on September 15, 2024

That makes sense, thank you! Should I close the issue?

from zig-sqlite.

vrischmann avatar vrischmann commented on September 15, 2024

No worries ! I'll close the issue.

from zig-sqlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.