Comments (5)
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.
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.
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.
That makes sense, thank you! Should I close the issue?
from zig-sqlite.
No worries ! I'll close the issue.
from zig-sqlite.
Related Issues (20)
- Testing with dbfile and in_memory=false options fail HOT 1
- Can't create a new database HOT 9
- Build failure using example usage HOT 5
- Document the virtual table feature
- Document the loadable extension feature HOT 1
- Make allocators optional for custom struct binding HOT 1
- Readme out of Date Linking Instructions HOT 7
- Can't fetch package using the Official package manager HOT 5
- translate-c name mangling causing compilation issues
- [RFC] - Finalizing a prepared statement that thew an error shouldn't log the error HOT 5
- exec expects two arguments, but README only lists one argument. HOT 1
- Build panics on aarch64 HOT 1
- Build panics when specify a glibc version HOT 1
- Does not work on latest Zig HOT 1
- "PRAGMA journal_mode = WAL" gives "panic: invalid result code 100" HOT 1
- Is it not possible to do something like that ? HOT 2
- error: 'workaround.h' file not found HOT 3
- Possible improvement on errorFromResultCode HOT 5
- remove dummy_diags and embed a default diag in Db for use HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zig-sqlite.