To connect to the database I use this example. But I can't find lessons on how to create a database.
For example:
connect to server
create new database
do something
drop database
close connection
Can anybody show me how to do it?
Thanks!
Follow the manual on how to create a database cluster:
http://www.postgresql.org/docs/9.1/interactive/creating-cluster.html
The database and users are created only once and you can use the client applications for that. Or are you trying to do it automatically as part of a software install package? After that you connect to it as many times as needed.
Since you are creating a new database and then dropping it, why not use the built-in SQLite database? You can do a completely in-memory database that will be lightning fast (unless you fill up available RAM).
I believe you can create databases by issuing standard SQL commands just as you can create tables in a database, as long as you are using a user (e.g. admin or similarly entitled user) that has permissions to create new databases.
So, all you need is to connect to the DB with the right user and then issue SQL commands with db.SQLExecute, such as "create database newDBname".
Related
My question is: when I create a PostgreSQL user different from the default postgres user, should I also create a new database for that user to connect to?
What's the point of a setup like that?
A few explanations:
Don't use the postgres database for user data. It is intended for administrative purposes, for example as a database to connect to if you want to run CREATE DATABASE.
This has nothing to do with users.
Users are cluster-wide, that is, all databases in a cluster share the same users. Note that that does not imply that every user can connect to each database.
PostgreSQL command line programs have two defaults:
If you don't specify a database user, the default is the database user that is called like the operating system user.
If you don't specify a database, the default is the database with the same name as the database user.
I assume that it is this last default that inspires your question.
This is just a default value and should not influence your database design.
Create one database for each separate body of data, like all the data that belong to one application.
Create users as your application and data maintenance procedures require. It is a good idea to use different users for different tasks. For example, the user that performs the backup should not be used by your application to connect to the database.
No. Even if it's a local admin user so you don't need to go through sudo, you should just add export PGDATABASE=postgres to your .bashrc or .profile. I always make a new superuser with the name of my local user, and configure pg_hba.conf to allow local connection if necessary.
I develop a multi tenant application where each tenant has its own mongo db.
All tenants share the same UI.
I should have one mongo db for all users accounts and each mongo db for data.
I'm new in meteor and i would like to know how i can dynamically select the database when i publish the collections.
export const collects = new MongoObservable.Collection('collectionname',{
connection:DDP.connect('urltomongodb')
});
Any help please
As far as I know the DDP utilities are available for people who wish to connect to a Meteor server from a non-Meteor platform, either front end or server.
There is, of course, nothing to stop you using DDP.connect() to connect to another server, but you will also need to manage that connection, and any retries etc if it becomes unavailable.
I would suggest an easier path is to manage all of your data in one database - trying to separate them becomes non-trivial, because it is doing something that Meteor doesn't normally do. If you structure your data accordingly, it should be quite feasible to keep all the data in one database
I'm trying to export all my users from one identity server instance to another. This includes all the roles that these users are part of, their permissions and claims.
What is the best way to export these users in bulk, and then importing them in another WSO2IS instance? The WSO2IS documentation is very limited about this subject: https://docs.wso2.com/display/IS500/Configuring+Users#ConfiguringUsers-Importingusers
Both IS instances have a postgres jdbc DB and have it running as a primary user store.
I believe you have to use separate databases for different IS instances. Otherwise you can just configure the same database in the new IS instance.
If you want to use a separate database, exporting the database dump from current user store database and importing to the new one/ create new using the dump should work.
I want to have two schemas(except public) in a pgsql database on heroku. On local I have done it like imported the data to public schema and renamed it to the name of my choice. In the similar manner i created two schema under one DB and connected it to a rails application using
search_schema_path: 'schema1, schema2'
Now I want to do the same on heroku and tried the same procedure. But it seems that, rails can not find tables from the DB. I am getting the error relationship "delayed_jobs" does not exists. Please suggest me how to do it.
Thanks in advance for any help.
When your Rails app is deployed on Heroku, an automatically generated database.yml over-writes your applications database.yml, which is dropping your schema_search_path setting, reseting it to public.
You can add an initializer that reset the value after load. For example, config/initializers/postgres_schema.rb:
ActiveRecord::Base.connection.schema_search_path = 'schema1, schema2'
You'll need to be careful to set this anywhere you're re-connecting or re-setting.
I want to write a C++ administrative app to simplify management of DBs I am in charge of. Currently, when I want to tell if there are users connected to multiple Firebird databases operated by 2 different instances of it, I have to connect to every single DB and check. That's ok, but I don't want to register every new database that is being created when i don't look, I want some way to list databases that are currently open or otherwise in use by the server. Current 2 uses of this functionality I can think of are:
Auto-inclusion in backup procedure
Application update, which require users to log off (one-look and I would be able to tell whom to kick or at least which department to call)
Firebird does not have an API to list all available databases. Technically Firebird simply doesn't know about the existence of a database until you actually connect to it.
You might be able to find all databases that are being connected to using the Trace API or the monitoring tables, but that does not exclude the possibility that other databases exist on your system.