How to duplicate/clone a database in MongoDB with C# - mongodb-.net-driver

At some events, I want to call a function, that should make a copy of the database and save it as a new MongoDB database with it's name as current Date time.
I just need the C# syntax to copy/duplicate/clone the mongodb database.

Related

Create mongodb database using Laravel command [duplicate]

I'm using a book to learn MongoDB. It says that in order to create a db in Mongo, I just need to 'use' it.
show dbs
admin 0.000GB
local 0.000GB
When I do, use someDBName
It says switched to db someDBName
But when I do show dbs
I just see admin and local again. I don't see the someDBName database.
It will not show until your database is empty.
To have your database shown you can use
create collection command to insert collection then it will be shown to you by using
show dbs
Per the MongoDB documentation:
If a database does not exist, MongoDB creates the database when you first store data for that database. As such, you can switch to a non-existent database and perform the following operation in the mongo shell:
use myNewDB
db.myNewCollection1.insertOne( { x: 1 } )
The insertOne() operation creates both the database myNewDB and the collection myNewCollection1 if they do not already exist.

Is there a need in Neo4j to have initial scripts just like rdbms store needs initial CREATE(and other DDL scripts) scripts to insert,update etc?

I recently was working with liquibase which is capable of generating the initial DDL script for my JPA entities.
I am trying to do the same for my entities which has Neo4j as the store. Is there any library like liquibase which I can use to get my work done. Can someone put light on this ?
Is there a need in Neo4j to have initial scripts just like rdbms store needs initial CREATE(and other DDL scripts) scripts to insert,update etc ?
I don't want to use the auto capability of spring boot.
There is no need in Neo4j to create or update schema itself, as you're doing in SQL. Schema is dynamically builds from the data you have in your database.
But if you're trying to manage migration of the data stored in your database, you can take a look at liquigraph. It's able to manage a CYPHER queries within changesets.

Capture or log the SQL queries, which Oracle database receive

I want to export information from a windows application, which manage the data in an Oracle database.
The problem is, I don't really know the data model e.g. all the tables and relationships, which save the information I need.
I thought, over the application GUI I could create some dummy data, display some data etc. and listen what the database receive(tables, columns etc.).
Is there an Oracle tool or any other appropriate tool, which I could use to capture the database queries, which the database receive?

How to load a H2 database into memory?

I have written a set of unit tests using H2 in embedded mode. Whatever changes tests make to DB stay there.
I know that the recommended approach is to create a blank in-memory database and create the schema when opening the connection.
However I am looking for an alternative approach. I would like to -
Initialize an in memory database with an embedded database file.
Or use embedded db in a way that all the changes are discarded as soon as the connection is closed.
How can I achieve this?
What I do in cases similar to this is to write the SQL script that creates the database and populates the tables. Then the application applies a database migration using Flyway DB.
Other possibilities are to create the database and load the tables from CSV files. The other would be to create the database with a different application and create a file with the SCRIPT command to create a backup. Your main application would have to run the RUNSCRIPT command to restore the database.
I use SQL scripts that create tables and other objects and/or populate them, and run these scripts at the beginning of the application.
One could also create a copy of the populated on-disk DB, package it into a ZIP/JAR archive, and open it read only, to be used to recreate and populate the in-memory DB.

Do I need to add a DB file to the project to us LINQ to SQL?

In our legacy SW we make our own wrapper classes to perform DB command and query. Now we want to switch to .NET 4 and want to use LINQ to SQL. But I am not quite sure whether it is mandatory to add a .mdf file to make it work.
Because we have our database service running already, and we would like to keep using the database on it(because our customers would want to keep using their databases), obviously we don't want to distribute a brand-new database file with our SW. But every article I found about LINQ to SQL says that I need to add a .mdf file to the project to make it work. So how should we do that? Can we use LINQ without assigning any database in the development?
Thanks!
LINQ to SQL doesn't require a local .MDF file in a project to work. You can generate LINQ to SQL classes against an existing remote database. Just connect to the server in the Server Explorer and drag tables to the LINQ to SQL designer.
Many people use the .MDF file in examples simply because it's a small, self-contained database. It's a convenience to the demo, not a requirement.
Additionally, it's possible to create a .MDF file with a schema that matches a remote database and work against that file during development but simply switch connection strings to go from a local file to a remote database.

Resources