Database Location in Scheme - database

I have a program which make use of a local database (sqlite3 and i use db module). What i want to do is using the database without knowing where it is.
For example, if i code the location of database in my program (like C:/my documents/my program/localdb.db), it is working correctly.
But if i just write "localdb.db", it doesn't find the database even if database is in the same folder with the .rkt file which use the database. (i dont know how but in earlier versions of my program, it was working).
Thus, how can i ensure to use the database without coding its location?
Thanks a lot!

Instead of "localdb.db", try using a runtime-path like this:
(define-runtime-path localdb "localdb.db")
and use localdb in place of the path string. You'll need to (require racket/runtime-path).

Related

Delphi, Microsoft Access 2007 Connection String

I've been trying to create a program that creates a database, creates tables, stores information in these tables, and reads off these tables. I am using delphi and microsoft access (although I am open to using another database program if one is easier to learn). Anyway, I cam across this question and answer: Delphi 7: ADO, need basic coding example
However I am confused about what my connection string would be or how to know what is is. I want the database saved in the same file area as where my program is so would it just be the file directory to that area such as:
FILE NAME=E:\project\Debug\Win32\Studentdb.accdb
Also the user uses +database. If my database name is Studentdb would I just put 'Brill1' in that space or not?
Also do I need to use ODBC connector if I am not using MYSQL? I am guessing not but do I need to use something else. Also, while saving files from microsoft access they save as .accdb however when I created a ADOConnection component on my form and pressed into the connection string property it was asking for a .udl and I haven't run across this anywhere before so I am wondering if I need to convert or do something with that.
I am a real beginner with this so I am sorry if my questions are obvious but I would really appreciate some help or pointed to a beginner's friendly resource on the subject. Thank you.
All possible connection strings from Access 2007 are here:
https://www.connectionstrings.com/access-2007/
...which one to choose depends on which driver you have and/or want to use.
(ACE, OLE, ODBC ...)

How to pass database name dynamically to RoundHousE

I am trying to setup the RoundHousE project in my application to handle the database migration and version handling. I am following this article. It is fine as far as I know the database name exactly.
But I am not able to find, how should I handle the dynamic name of databases, because in my application I have separate database for each client, and list of these databases in a table in my main database. So name goes like: client1_db, client2_db etc.
Any solution or pointer towards the solution will be a great help.
A pointer towards the solution - The wiki https://github.com/chucknorris/roundhouse/wiki
Asking about passing the database name dynamically is a bit weird to me as when you run rh.exe or use the embedded DLL, database name is one of the required arguments. So you always have to pass the name dynamically. See https://github.com/chucknorris/roundhouse/wiki/ConfigurationOptions#main-stuff
Reading and trying to understand what you are asking, it seems you have a list of database names in a main database somewhere that you want to give to RoundhousE? To do that you would need to create something custom that can gather the name of the database(s) you are looking for and provide the result to RoundhousE.

How we can make ms access db embed in winform application to make it portable

Can any please explain that how we can embed ms access db in our winform application so that it could easily run on other machines with just one file .EXE . i have serached a lot but still unable to find an appropriate solution for it.Thanks in advance.
Assuming you are using an MDB, then the (32 bit) database engine (JET) is part of Windows. As such, there should be no setup requirements for that. If the database is only read and not written to, then you can add it as a resource to the EXE, and when the application starts up, extract the resource into either the TEMP directory, or if it's large and you don't mind leaving caches about, into a subfolder under local application data (CSIDL_LOCAL_APPDATA). If you do the latter, then the next time the application starts it can check to see whether a valid extracted MDB already exists and use that if it does. You can do a similar thing if the database is to be written to, but only for local storage, in which case the linked-in MDB would serve as a 'template' database.
If you were using Delphi or C++ I'd also suggest investigating SQLite as a possible alternative to JET, though as it's C# I assume (the 'c' tag is a bit confusing) then you won't be able to statically link the SQLite code, which fails the standalone EXE requirement.

Work with Database using Spock and Geb.

I hope someone have already faced an issue to verify that application shows correct data from database. I reviewd how groovy used SQL, but I have no idea where and how I should do that. I'm just starting to use gradle+Spock+Geb for testing application. I have a few files where I described a couple of pages from application, a couple of modules and a file with spock specification. Where and how I need to connect to Oracle DB, use SQL and compare result's data with application's ones?
P.S. I write everything in notepad++ and launch from command line writing 'gradlew firefoxTest'. Does exist any more comfortable way to work with gradle+spock+geb?
Thanks in advance.
Because there are no other answers, I wanted to provide a solution someone at my company thought of. This assumes you already have a project that uses some sort of JDBC. In our case it is JDBI.
The idea is to extend Classloader and then use that to directly access the data access object class via the JVM. That idea should work.
I have not tested it out because it doesn't completely fit our use-case. I'll admit that this does not completely apply to your use case, but technically you could just run the jar of an existing project, which can access the database.

Codenameone: access sqlite outside application dir/database

How can i Access a SQLite DB which exists outside the application/database dir?
Looks like openOrCreate alway point to the appdir/database
You can only use getDatabasePath to get the path for the DB and assuming it is not null copy the file into the given location. The reasoning is that database might not be SQLite so it won't necessarily consist of one file. There is also the issue of filesystem which isn't very portable between platforms.

Resources