This is my first experience with CRUD databases. I am facing some issues with the connection and I am not finding the awser on internet;
So, I have already a nuxt project developed and I am using postgresql that has already a table created just for an exemple.
How can I make my web pages on nuxt to read the data from table on localhost?
Table Postgresql Properties
Hostname: localhost;
Port: 5432
Username: postgresql
Password: ?
Which technology do I have to use? I was trying to do with axios, but It did not work for me.
I was trying to do like the code below. Do I am in the rigth way? Thanks in advance
actions: {
axios({
method: 'post',
url: '/localhost:5432',
data: {
firstName: 'Fred',
lastName: 'Flintstone'
}
})
Related
I'm trying to connnect to Mongo DB Driver and I am getting this error:
This is code I copy and pasted from the starter documents on the website. I changed the hostname to my first and last name and the uri connection to my server:
Any help is appreciated.
I have also faced this issue, while trying to create a demo app, I updated my password using autogenerate password, i.e I clicked on auto generate password and pasted it in connection string, it worked for me.
Instead of mongodb+srv:// you should be using mongodb://
DNS SeedList Format
mongodb+srv requires additional settings on DNS which contains seedlist, commonly use for sharded clusters and replica set
https://docs.mongodb.com/manual/reference/connection-string/#std-label-connections-dns-seedlist
Standard Connection String Format
If you are connecting to a standalone you should be using the standard connection string format.
mongodb://<username>:<password>:<IP/Hostname>:<Port>/<database>
https://docs.mongodb.com/manual/reference/connection-string/#standard-connection-string-format
Creating User with Password
To create a username with password you should be using db.createUser() which can be found here.
https://docs.mongodb.com/manual/reference/method/db.createUser/
Example ( To create a Admin user )
use admin;
db.createUser({
username: 'brianlevin',
pwd: passwordPrompt(),
roles: [ { role: 'admin', db: 'databasename' }]
})
I am new to sails and its connection to database. I plan to use Heroku to host my app so I would like to use Postgresql.
I have changed config.datastore file with the following code:
default: {
adapter: 'sails-postgresql',
url: 'postgresql://postgres:postgres#localhost:5432/postgres',
max: 1
}
On Sails documentation it sais that url is url: 'postgresql://user:password#host:port/database', but I dont understand where should I get user and password from. Do I need to initiate the postgresql and set it up and define a new database?
I am just trying to understand the mechanics behind this setup.
What you need to do is create a new user for your local PostgreSQL instead of using the default user and database. What I mean is, create a user-specific to your particular project in SQL following this should help https://www.postgresql.org/docs/8.0/sql-createuser.html.(This should also help you set the password)
Then create the database you want to connect to your Sails app to be used by Waterline by following this: https://www.postgresql.org/docs/9.0/sql-createdatabase.html (make sure you grant the user you created permissions for this database as well https://www.postgresql.org/docs/9.0/sql-grant.html)
Then all you need is replace the url property value in config/datastore.js with the value following the format
postgres://USERNAME:PASSWORD#localhost:5432/DATABASE_NAME
N.B: Replace USERNAME, PASSWORD, and DATABASE_NAME with the actual username, password, and database name respectively.
When you are deploying to Heroku, Heroku would provide you with an environment variable called DATABASE_URL if you install the Heroku Postgres add-on. You could just pass that to url like so
url: process.env.DATABASE_URL
My problem is that I'm new in JHipster. I can construct a basic application using the H2 disk persistance method to develop and it works fine, but when I try to build a new project using the Postgres db as development method, and I configure de database attributes in the application-dev.yml file, it just doesn't work, I can't even log in.
Can anyone help me with this?
Here is the fragment of the application-dev.yml file where I configure the access db. Of course I've already created the database (ControlAcceso), but it's empty, I thought the tables creation will be automatic, please correct me if I'm wrong.
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:postgresql://localhost:5432/ControlAcceso
username: postgres
password: root
hikari:
poolName: Hikari
auto-commit: false
If you are able to use docker you could add testcontainers when using psql also in dvelopment to get similar experience like using h2 https://atomfrede.gitlab.io/2019/05/jhipster-with-testcontainers/
I am brand-new to Sails and I'm looking to build my first application in javascript land! I am currently trying to connect my sails application to a postgresql database and I want to make sure that I am doing this correctly.
I started by creating a postgresql db with dbName, userName, password. I have added all this information into my connections.js file:
somePostgresqlServer: {
adapter: 'sails-postgresql',
host: 'localhost',
user: '<username>', // optional
password: '<password>', // optional
database: '<databasename>' //optional
}
I want to be sure I can migrate and perform all operations on my own so my models.js is set to migrate: safe. I ran npm install sails-postgresql. Now, to my understanding if I have migrate set to safe I will need the sails-db-migrate module (https://github.com/building5/sails-db-migrate). I followed this module step by step. I generated a User model by running sails generate api user. After this I ran grunt db:migrate. After all this, I check my psql database and no User table has been created. I know there is something I am missing, or maybe there is a more simple way to see if my postgresql db is connected.
Any advice or suggestions on how I should approach this would be greatly appreciated.
I was able to connect my PSQL DB to my application by simply:
creating db in psql
configuring it in sails app/connections.js
running npm install sails-postgresql
Adding to config/env/development.js:
models: {
connection: 'somePostgresqlServer'
}
running sails generate api user
sails lift
When asked for migration mode I chose options 2 which is alter
Opened up psequal and sure enough there was my new user table.
I'm not sure which of these actually triggered it to working from adding my db name to development.js, leaving off a PW on my DB, or changing migration mode to alter. But these steps helped it to connect. Will look further into.
Any idea of how to connect to db2 in an sql file in an Eclipse application?
I spent hours on trying to connect db2 using the following statement without any luck
[CONNECT'jdbc:db2://localhost:50000/DB2ADMIN;create=true;user=db2admin;password=db2admin']
What I'm typing wrong?
I can ping the db and I can create tables but can not connect to it into my application
please help....
Are you sure about your connection string:
Server: localhost
Instance number: 50000
Database name: db2admin
Username: db2admin
Password: db2admin
It is weird to have a database called db2admin.
What is the purpose of the 'create' option in the URL. I did not found that in the documentaion.
For more information about how to define the URL, please take a look at this page: http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_rjvdsprp.html