What's up with SQLite and Jetbrains Rider
I am debugging a metod and its saying a row is missing from the table. This made no since, so i wiped open SQLiteStudio and took a loo at the file. the row is there alright.
So i add a breakpoint and check the connection.
The connection has a property, FileName, that i assume has the FilePath of the sqlite file. its pointing to a file in /bin/debug file, not my sqlite file.
what's up with this??? why not point at the file in my primary directory?
108 Replies
because that's not the typical working directory for C# programs
the default working directory is the location of the built executable
if you have data that you want copied to the output folder, you can configure that per file in the IDE by right clicking the file and going to properties
or use an absolute path instead of a relative one, then it doesn't matter what the working directory is
would that be a build action?
no, it's the "copy to output directory" option below that
oh, i see that
build action should be none for regular non-code files
is there a way i can make changes come back when we are done building?
what do you mean
if you want to work on the file your program is also working on, just put it in the bin folder and don't have anything in your source folder
so my program makes changes to this database. idealy is back here where i can look at it once the program makes changes
or use the absolute path option
k, i will have to put that in a config so i dont screw this up when i finish this and deploy it
thx
so thats what a bin folder is...
amazing ive gotten this far not knowing that.
yeah that's where your actual program ends up
very very good to know
if you wanted, you could copy those files to some other place/computer and run the exe and it would run
(assuming the .NET runtime is installed)
no clue! my c# class didnt do much more than mention .NET existed. frankly not sure what the diferance is between c# and .NET
it's basically all the libraries and other guts that make your C# program actually run
mostly they pushed me off to c++ and i was like nope.
oh. i would just call that c#... weird
well, it's different because C# isn't the only language that runs on .NET
there's VB.NET, F#, and some others afaik
they all use the same underlying libraries and runtime
nifty. well, i am still getting that weird error about the row not being there for some reason.
aaand now SQLiteStudio cant resolve the db
boy i am screwed.
are you trying to open the right file?
yea
welp. guess this is a problem for another day. gtg now.
if you want to automate the sharing of that file, it's all custom
there's no checkbox to help you
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
Why not use DB Browser :SCfeet:
I haven't read the convo here yet just small parts of it
But your issue sounds more like a rider issue, what you did there I do all the time in Visual Studio, and there it works properly
The behavior you're explaining I experienced with ASP.NET before for some reason and no one was able to explain why this happens
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
I am not doing that.
I just have it in bin
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
there's a lot of stuff ive got hardcoded rn, that wont be eventually. filepath to the database is one of those things
i didnt ever set up copy to output directory. i leaned what /bin was and just put the db file in there perminantly.
i see the issue your talking about. that could actually be really useful for testing, allowing me to quickly reset the state of the db for testing, but it woudl mean i couldent save anyting between states unless i update the file manualy.
use EF Core!!!
use what?
oh, entity framework
no idea what that is
people keep talking about it as if everyone knows what it is
anyone see any issues with this connection string?
i am now getting an unable to open database error
the path separators are wrong for windows, idk if sqlite cares
they should be \ not /
swapped them no change :(
private const string DatabasePath = "C:\\Users\\<username>\\Desktop\\GhostOfJoe\\hostOfJoe\\GhostOfJoe\\bin\\ServerData.db";
to me its the most powerful way of interacting with a database
works on any SQL database too :soPortuguese:
sounds great
yes!!!
its simple to setup too
no more writing of SQL queries no more query to object parsing only productivity!!!!!
(not a replacement for knowing SQL)
yes!!!
well i actualy realy like sql, so thats not all bad
the main advantages of EF Core are the object mapping and type safe queries, and less "not having to write SQL"
because you absolutely still need to know the actual SQL that EF Core will produce to avoid writing bad queries
can someone point me to a good walkthough for ef?
there's a getting started section in this documentation https://learn.microsoft.com/en-us/ef/core/
Overview of Entity Framework Core - EF Core
General introductory overview of Entity Framework Core
that is a good place to start at the very least
working on setting up EF.
trying to scafold my database (i am using rider so no commandlit)
dotnet ef dbcontext scaffold "Data Source=C:\Users\<username>\Desktop\GhostOfJoe\hostOfJoe\GhostOfJoe\bin\ServerData.db;" Microsoft.EntityFrameworkCore.Sqlite --context-dir Data --output-dir Models
this crashes with this error
SQLite Error 14: 'unable to open database file'.
so something is wrong with my connection string and or file
Anyone know whats up with my connection string?found this (https://stackoverflow.com/questions/10875612/unable-to-open-the-database-file) and it seems to sugest i need a version=3; statment, but when i include that i get an error:
Stack Overflow
Unable to open the database file
private void SetConnection()
{
string a = string.Format(@"Data Source={0};Version=3;New=False;Compress=True;", "~/lodeDb.db");
sql_con = new SQLiteConnection(a);
}
pr...
Connection string keyword 'version' is not supported.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
no, 6 tables, no data as of yet. just had to rebuild it
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
i am practicing for a larger database with something like 60 tables
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
did the code.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
i figured if i could get it working with the small database, where i can debug easer and know quickly if its right and i can scale it.
on top of that, the issue with not being able to access the SQLite database is not just with this command. I get the same error trying to access the data from my code
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
yea thats why i am trying to get it to work. but if i cant even connect to the database i am not going to get very far.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
why?
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
that would be a problem yes
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
ok. so where do i put my config.json file?
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
ive seen appsettings.json and i know there is some fancy way of accessing it. I dont know it. I just implemented my own quick method to grab data from a config.json file
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
fancy way of accessing it within the code, not the editor
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
give me a few min. i gotta throw some kinda sensitive stuff in a config before i make that repo public
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
weee. welp its not a big issue. i can always regenerate it.
no it just the private key for my discord bot
which i can just rebuild in like 2 min
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
its so losely attached to my code and still in development so its just on my private server
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
yep.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
glad i am making these mistakes on the prodotype
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
ok. i gotta start from the begining. gotta figure out secrets
like i said, fancy stuff no one ever explanes for some reason
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
yea thats a good idea. the bot doesent even run in the current state anyways.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
this is not how to get an enverimental vars...
i dont know how of if there is an extra step, but this is not it.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
what....
hm. ah. bet i got it
ok. got that
ok. thats the only truely sensitive bit of info in the system. everthing else is server/channel/user ids which i am falry sure are all publicly accessable anyways.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
nope. all discord ids.
the only identifying info ive got is the id of peoples discord users, (publicly accessable) and the if servers they are in (also publicly accessable)
but also, the db is empty rn... so... none of that data. The end state of the projct will be that the database will per persistant on a server somewhere and i will modify the cs project and push the build to the server and restart it.
but i havent gotten there yet.
worst think that could happen is people might be able to DM a frend of mine while not being in the same server as him which is not really an issue as there would be easer ways to find him.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
ok... making repo public...
here you go: https://github.com/hutonahill/GhostOfJoe
GitHub
GitHub - hutonahill/GhostOfJoe
Contribute to hutonahill/GhostOfJoe development by creating an account on GitHub.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
good to know. will fixt that right off the bat
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
nope, its in the bin which you cant cuz its
.gitignore
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
same. here let me zip that real quick
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
great. downgraded the packages to .NET 8
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
yep. most of them are still on 8.0.0, but a few are newer.
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
i just went into NuGet, uncheck pre release, then downgraded all the packages
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
hm.... whats the reason to use appsettings.json over my config system?
because, like the op for this stack post, i need to modify my settings programmatically. I've already got my bot set up so i can modify the settings from it... so i think i am just not going to use the appsettings.json system...
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
what does this mean?
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
hm. well ive kinda already done that with my config system...
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
ok. fine *grumpy noises * i will figure DI
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
ok. lets start with my requirements
1) i need a place to store a handful of my bots settings i don't want to store in SQLite. current solution is a config.json file. I need to be able to access my config object within my program and i need to be able to programaticly make changes to it.
2) i need a safe place to store secrets like my API key.
can
Host.CreateDefaultBuilder
do this?
also, this is not a window form application. Its command line
so i assume a line like this: services.AddSingleton<Form1>();
needs to be somthing else
(ive got to sleep. be back in a few hours)