I'm working on a project in which I have store csv file data in my mongodb. If the database is not exist then I have to create it using springboot and if does exist then I have to directly store the data in db
Previously I stored all the data in "admin" database in mongodb.
Below is the for the same. In my properties file I specified this.
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.uri=mongodb://localhost:27017/admin
spring.data.mongodb.database=admin
spring.data.mongodb.repositories.enabled=true
you don't need to create a database just replace admin with the name of the database you want to create mongoDB will create automatically
like this :-
spring.data.mongodb.uri=mongodb://localhost:27017/newDatabaseName
spring.data.mongodb.database=newDatabaseName
Related
Whenever I create a new database from pgAdmin or using the command line (using CREATE DATABASE database_name), it's not empty.
It contains some tables that are part of a previous project I worked on.
I'm not yet very familiar with Psql so I don't know what I'm doing wrong.
You probably have created objects in the database template1.
Quote from the manual:
By default, the new database will be created by cloning the standard system database template1. A different template can be specified by writing TEMPLATE name. In particular, by writing TEMPLATE template0, you can create a virgin database containing only the standard objects predefined by your version of PostgreSQL. This is useful if you wish to avoid copying any installation-local objects that might have been added to template1.
So, anything that is in the template1 database will be copied over to the new database when you run create database.
Connect to the template1 database and drop all objects you don't want.
I'm using OrientDB 2.0.2. I'm writing a SQL script that will create a new DB, construct the schema, and then populate the DB with static initial data. I know that the database will be automatically created if I simply start loading data, and that classes will automatically be created if I start inserting records, but I want to make sure that my classes have the right inheritance and Properties and Indexes before I begin my data load.
The SQL syntax is easy - I just need to know how to run the SQL script from the command line in order to instantiate the the DB, as if I were deploying a new instance of my DB at a new location, or for a new customer.
Thanks.
Assuming you installed OrientDB in the base directory ORIENTDB_HOME, then go to the $ORIENTDB_HOME/bin directory. In this directory, execute the OrientDB SQL Script with the simple command:
*nux:
$ ./console.sh myscript.osql
Windows:
> console.bat myscript.osql
mysql.osql is a simple text file, containing all SQL command (.oslq is a typical file extension for OrientDB SQL scripts).
See documentation for details how to create a new database. Example:
CREATE DATABASE plocal:/usr/local/orient/databases/demo/demo
or
CREATE DATABASE remote:localhost/trick root verySecretPassword
Whenever I create a new database from pgAdmin or using the command line (using CREATE DATABASE database_name), it's not empty.
It contains some tables that are part of a previous project I worked on.
I'm not yet very familiar with Psql so I don't know what I'm doing wrong.
You probably have created objects in the database template1.
Quote from the manual:
By default, the new database will be created by cloning the standard system database template1. A different template can be specified by writing TEMPLATE name. In particular, by writing TEMPLATE template0, you can create a virgin database containing only the standard objects predefined by your version of PostgreSQL. This is useful if you wish to avoid copying any installation-local objects that might have been added to template1.
So, anything that is in the template1 database will be copied over to the new database when you run create database.
Connect to the template1 database and drop all objects you don't want.
I am working on a new Rails application with MongoDB. Here I want to create a separate database for every user who registers into the application.
I am trying to create the database like this, here is my mongoid.yml configuration:
staging:
host: localhost
database: mongoid_<%= #user.username%>
Please help me to create separate database for every user in MongoDB.
I would prefer you to use separate collections for each registered user instead of separate dbs. But if you insist so use Moped session explained in this link http://mongoid.org/en/moped/docs/driver.html#behaviour
I am Using AppBuilder.In that if I am trying to connect to Sports2000 database.Even though there is a option to create a database its prompting to copy a database.Can I know the reason?
I'm not an app-builder user but I would imagine that it is creating a new db by copying an existing db. The standard candidates would be "sports", "sports2000" or "empty".
You can connect a database from the AppBuilder using Tools -> Database connections -> Connect.
You cannot connect to databases in the OpenEdge installation directory. These are only used as templates to create new databases.
When you create a new DB, you have option to start with:
Empty - to create a new empty DB
Copy from - copy DB Schema from other DB, such as sports, sports2000 or other existing DB.