I'm new to PostgreSQL and this is my first symfony project with PostgreSQL. When I try to run insert-sql in symfony, it tells me my database, salon, doesn't exist. But it does exist, as you can see below.
ason#ve:~/salon$ ./symfony doc:insert-sql
>> doctrine creating tables
PDO Connection Error: SQLSTATE[08006] [7] FATAL: database "SALON" does not exist
jason#ve:~/salon$ sudo -u postgres createdb salon;
createdb: database creation failed: ERROR: database "salon" already exists
It seems that any symfony command I run will tell me that salon doesn't exist (I've tried others). For this reason, my guess is that this is a symfony problem as opposed to a PostgreSQL or PHP problem.
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: pgsql:host=localhost;dbname=SALON
username: salon
password: foobar123
Any idea what I'm doing wrong?
Boy, do I feel dumb. If I use dbname=salon instead of dbname=SALON, it works.
Related
I have followed the various tutorials from philly and others to setup django with django-mssql-backend but have had no luck. I think the connection is working but when it is trying to parse the tables I get a collation error that it cannot get past. The specs of what I'm running are as follows:
django-mssql-backend: 2.8.1
django: 3.2
pyodbc: 4.0.30
'server':{
'ENGINE': 'sql_server.pyodbc',
'NAME': 'database',
'USER': 'username',
'PASSWORD': 'password',
'HOST': 'hostname of server',
'PORT': '',
'OPTIONS': {
'driver': 'ODBC Driver 17 for SQL Server',
'unicode_results': True,
},
}
When I attempt to run the migration class creator or:
python manage.py inspectdb --database=server
I get the following error in the output:
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
# Unable to inspect table 'ADObjectMemberships'
# The error was: __new__() missing 1 required positional argument: 'collation'
# Unable to inspect table 'ADObjects'
# The error was: __new__() missing 1 required positional argument: 'collation'
I am sure this is possible because I spooled up a different venv with django 1.8 installed and the old django-pyodbc-azure module installed and it connects to the tables and pulls their information. The biggest problem I have with it is that it stops with ~15 tables left in the DB and throws a memory error no matter what I do to fix it.
Any thoughts or help on the issue is greatly appreciated!
Confirmed through independent testing that the issue does appear to be a bug in version 3.2 and will put in a bug report. However I did come out with a workaround for now as follows:
Create new temporary virtual environment
Install django==3.0 pyodbc==4.0 django-mssql-backend==1.8
Create the database entry for the SQL Server in settings.py
run python manage.py inspectdb --database=yourentry > yourentry.py
Once you have created all the models for the existing database you want to use in your website you can grab each of the yourentry.py files and copy them to a submodel folder and import them into the main models.py file.
When the virtual environment is no longer needed it can be deleted.
I'm trying to run the project in Jhipster based on this tutorial by the creator himself :https://www.youtube.com/watch?v=d1MEM8PdAzQ but it can't connect to Postgres
See errors below:
Caused by: org.postgresql.util.PSQLException: The server requested password-based authentication, but no password was provided.
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:473)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:203)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:146)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:35)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:47)
at org.postgresql.jdbc42.AbstractJdbc42Connection.<init>(AbstractJdbc42Connection.java:21)
at org.postgresql.jdbc42.Jdbc42Connection.<init>(Jdbc42Connection.java:28)
at org.postgresql.Driver.makeConnection(Driver.java:415)
at org.postgresql.Driver.connect(Driver.java:282)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:95)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:101)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:316)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:518)
How do I connect Jhipster with postgreSQL? I am a newbie on jhipster
JHipster creates 3 configuration files: -
application.yml - main Spring Boot configuration file.
application-dev.yml
application-prod.yml
The application.yml file contains common properties, the other 2 hold specific properties to development and production environments.
If you look at application-dev.yml you'll see something like the following: -
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:postgresql://localhost:5432/myapp
username: myapp
password:
However, you still have to create your PostgreSQL database - the easiest way is via the pgAdmin tool but you can also create it via command line tools - a quick google will help you there!
If you don't want to work with docker compose file Version 3 in docker swarm mode, where it is best practice to use docker secrets, then you can create an .application.env-file and link it in your docker-compose.yml (Version 2) with 'env_file:'
$ cat .application.env
SPRING_PROFILES_ACTIVE=prod,swagger
SPRING_DATASOURCE_URL=jdbc:postgresql://postgresql:5432/database_name
SPRING_DATASOURCE_USER=database_user
SPRING_DATASOURCE_PASSWORD=database_password
JHIPSTER_SLEEP=10
[...]
At least I use it this way to keep the credentials away from my jhipster-projects, which are on Github, where I also want to put the *.yml-files.
Whenever i launch my app, part of my task is to first run a migration. however, I get the below error 95% of the time.
Command failed: /bin/sh -c node_modules/.bin/sequelize db:migrate
Unable to connect to database: SequelizeConnectionRefusedError: connect ECONNREFUSED
Details:
killed: false
code: 1
signal: null
cmd: /bin/sh -c node_modules/.bin/sequelize db:migrate
stdout:
Sequelize [Node: 0.12.7, CLI: 2.1.0, ORM: 3.14.0]
Note: I can still query and connect to the database after the failure, also when i check the TCP lsof -i tcp:5432 its only one instance of postgres that runs.
I would appreciate any assistance in solving this issue.
I had similar issue , but in my case it turn out I didn't start my posgres. Make sure your posgress is started and open otherwise Sequelize would fail. I just solve mine. Also mind your username and password . my connection is simple below.
var db ='postgres://user:#localhost:5432/my_db_naame'
var sequelize = new Sequelize(db);
where user is your database user . my_db_naame is your db name. See the doc here . I suggest you install posgres client terminal. Like the one here http://postgresapp.com/documentation/gui-tools.html . Make sure you open it and the elephant sign is shown on top . Or better connect , try your username and password. run some queries and then try your sequelize again.
I am new to DB2 and I have installed DB2 9.7.
I created an instance which is shown below
[sathish#oc3855733574 ~]$ db2ilist
sathish
Settings of /etc/services is shown below
DB2_sathish 60000/tcp
DB2_sathish_1 60001/tcp
DB2_sathish_2 60002/tcp
DB2_sathish_END 60003/tcp
DB2_TMINST 50000/tcp
But, when I start using 'db2start' it throws the following error
07/31/2015 10:26:20 0 0 SQL1042C An unexpected system error occurred.
SQL1032N No start database manager command was issued. SQLSTATE=57019
I installed DB2 using 'root' and starting 'DB2' from 'instance' (sathish in this case)
Any help or URL link will be of great use
Thanks
Sathish Kumar
I had a look into db2diag.log file and I got a unusual hack from one of the website
I followed the steps mentioned below and it worked
a) db2trc on -f db2trace.out
b) db2start
c) db2trc off
This problem generally occurs if you have recently changed the password of the account which is the owner of that db2 instance what you need to do is go to services-> properties of the db2 instance -> and then from log on part select local system account
This looks like something is wrong with the installation. There should be some hints on what DB2 ran into in the db2diag.log file (look under ~/sqllib/db2dump/db2diag.log).
What you could do if the db2diag.log does not provide a clue is to verify your installation is correct. DB2 includes a tool for that named "db2val". Here is the link to the documentation of db2val for version 9.7. Just run "db2val" as the instance owner and check the output.
Try
sudo -i -u db2inst1 /database/config/db2inst1/sqllib/adm/db2start
For more information
https://dba.stackexchange.com/questions/49807/sql1641n-error-on-linux-while-running-db2start-using-db2-express-c-on-linux-luw
i tried to create a new database in Doctrine, with php app/console doctrine:database:create but i got an error : i fixed it thanks to this website
now i've got a second error, but i can't find any solution :
afther this :
pc11:Symfony Paul$ php app/console doctrine:database:create
i've got this error :
Could not create database for connection named symfony
SQLSTATE[28000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
i tried without "symfony" but it did not work :
pc11:~ Paul$ php app/console doctrine:database:create
Could not open input file: app/console
Would you know how to fix this?
Thanks
You're probably missing database configuration, it tries to connect to MySQL as the user root without a password and fails to get the permission to create the database.
Check your parameters.ini for settings related to the database connection.
You need to set the password for root#localhost to be blank. There are two ways:
The MySQL SET PASSWORD command:
SET PASSWORD FOR root#localhost=PASSWORD('');
Using the command-line mysqladmin tool:
mysqladmin -u root -pCURRENTPASSWORD password ''
Solution
This worked for me on Mac OS X with MAMP (or MAMP Pro).
Add database.unix_socket in app/config/parameters.xml
parameters:
database.driver: pdo_mysql
database.host: localhost
database.port: 8888
database.name: my-database-name
database.user: root
database.password: root
database.unix_socket: /Applications/MAMP/tmp/mysql/mysql.sock
Add unix_socket in app/config/config.xml
# Doctrine Configuration
doctrine:
dbal:
# ...
unix_socket: "%database.unix_socket%"
I was having the same problem.
If you want to try with php you have to change app/console to bin/console