could not init postgres with a dump file - testcontainers

just starting testcontainers. I love the idea. thanks for investing in this project.
I am trying to create a simple postgres 14.5 container (and susceeded) and now I am trying to populate it using the .withInitScript() method.
the file I am feeding into the init method is a dump I created with pg_dumpall.
testcontainers fails for many parsing/validation reasons. each time I delete a portion and another reason pops up.
should I be able to succesfully use the withInitScript with pg_dump files?
BTW, using pg_dump for my main DB also has many similar issues.
thanks!

Try copying the script to the container so postgres will execute. Although this comment BTW, using pg_dump for my main DB also has many similar issues. makes me wonder if it will work because it also fails when you are using the database directly if I understood correctly.
new PostgreSQLContainer("postgres:14.5")
.withCopyFileToContainer(
MountableFile.forClasspathResource("init.sql"),
"/docker-entrypoint-initdb.d/init.sql"
);
We recommend to use liquibase or flyway to manage database changes.

hi and thanks for the help
I have managed to make things work by stripping some things from the sql dump and using the copyFileToContainer
thanks

Related

Create an H2 Database from the console

I would like to run H2 on my local host (Windows), and create a new database.
To do so, I have dowloaded the zip file from http://www.h2database.com/html/main.html, unzipped it, then run the bin/h2.bat script. I have not used the windows installer, as the machine I will be running later on does not grant me installation privileges.
The console was successfully opened on the 8082 port, but I could not create any database, failing with Database "C:/Users/PC/test" not found [90013-198] 90013/90013. I have tried many variations, to no avail.
The documentation states that a database should be created automatically if it does not exist, but indicates it cannot be done so from the H2 console (http://www.h2database.com/html/tutorial.html#creating_new_databases).
However, the documentation does not provide an alternate way to create a database, either by running the jar with additional parameters, or by another utility.
I feel pretty dazed right now. How do I properly create a new database in H2? I would like a normal database, persisted on disk, not an in-memory one.
I would suggest that this does not work in version 198
You could download an older version (I used 196) to create the databse and then switch back to 198 to open the database.
I have managed to run it by using the following command line:
java -cp h2-1.4.198.jar org.h2.tools.Server -tcp -pg -web
I must have missed something in the documentation, sorry about this.

Where can I find the mongoDB database

i install the meteor package and within is the mongoDB. Now I made an easy application and create a mongo db collection ...
Todos = new Mongo.Collection('todos');
I write data in this collection and everything works fine. BUT! I can not find the mongodb and the collections an my Mac?! I read on some sites that I have to watch at /data/db but on my mac there is not such a file...
Can anyone explain where mongoDb takes the data on my Mac.
Thank you
Countless duplicates to this one if you use the search engine, but a short answer would be to look inside: .meteor/local/db

Embedded MongoDB instance?

I've been using MongoDB for a little tool that I'm building, but I have two problems that I don't know if I can "solve". Those problems are mainly related with having to start a MongoDB server (mongod).
The first is that I have to run two commands every time that I want to use it (mongod and my app's command) and the other is testing. For now, I'm using different collections for "production" and "test", but it would be better to have just an embedded / self-contained instance that I can start and drop whenever I want.
Is that possible? Or should I just use something else, like SQLite for that?
Thanks!
Another similar project is https://github.com/Softmotions/ejdb.
The query syntax is similar to mongodb.
We use this at work - https://github.com/flapdoodle-oss/embedmongo.flapdoodle.de - to fire up embedded Mongo for integration tests. Has worked really well.
I haven't tried it, but I just found this Ruby implementation of an embedded MongoDB: https://github.com/gdb/embedded-mongo

Heroku's db:pull/push seems to ignore sequences?

I've been messing around with the new Play framework 2.0 for a possible petproject. After deploying a testapplication to Heroku I wanted to perform some checks to see how I can manage my data which will be stored into Heroku's postgresql database.
I stumbled upon the db:pull and db:push command. Apparently it should be easy to take a dump of my development environment's db and overwrite the database of my production environment (and the other way around) with it. However while testing I noticed that it seems to ignore my SEQUENCES? Is it supposed to only copy the tables and their data? My schema is looking like this:
CREATE SEQUENCE task_id_seq;
CREATE TABLE task (
id integer NOT NULL DEFAULT nextval('task_id_seq'),
label varchar(255)
);
So my 'task_id_seq'-SEQUENCE is not being extracted for some reason. I tried it both from prod to dev and the other way around and they both leave out my SEQUENCES.
I hope that I'm overlooking something...?
Thanks in advance!
Edit: I tried out pgbackups to produce and place dumps instead, and it's working flawlessly.

Can you connect to a MS Access database from Ruby running on a Mac?

I'm pretty sure the answer is "no" but I thought I'd check.
Background:
I have some legacy data in Access, need to get it into MySQL, which will be the DB server for a Ruby application that uses this legacy data.
Data has to be processed and transformed. Access and MySQL schemas are totally different. I want to write a rake task in Ruby to do the migration.
I'm planning to use the techniques outlined in this blog post: Using Ruby and ADO to Work with Access Databases. But I could use a different technique if it solves the problem.
I'm comfortable working on Unix-like computers, such as Macs. I avoid working in Windows because it fills me with deep existential horror.
Is there a practical way that I can write and run my rake task on my Mac and have it reach across the network to the grunting Mordor that is my Windows box and delicately pluck the data out like a team of commandos rescuing a group of hostages? Or do I have to just write this and run it on Windows?
Why don't you export it from MS-Access into Excel or CSV files and then import it into a separate MySQL database? Then you can rake the new one to your heart's content.
Mac ODBC drivers that open Access databases are available for about $30.00
http://www.actualtechnologies.com/product_access.php is one. I just run access inside vmware on my mac and expore to csv/excel as CodeSlave mentioned.
ODBC might be handy in case you want to use the access database to do a more direct transfer.
Hope that helps.
I had a similar issue where I wanted to use ruby with sql server. The best solution I found was using jruby with the java jdbc drivers. I'm guessing this will work with access as well, but I don't know anything about access

Resources