I'm on Symfony and I can't connect to a Oracle database, but I don't know why. Maybe you can help me a little.
Here my doctrine.yaml
doctrine:
dbal:
default_connection: default
connections:
default:
# configure these for your database server
url: '%env(DATABASE_URL)%'
server_version: '5.7'
charset: utf8mb4
test:
# configure these for your database server
url: '%env(DATABASE_TEST_URL)%'
driver: 'oci8'
server_version: ~
charset: utf8mb4
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
test:
connection: test
mappings:
test:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Test'
prefix: 'App\Entity\Test'
alias: Test
My .env file with 2 database:
DATABASE_URL=mysql://xxx:xxx#mysql:3306/pivot
DATABASE_TEST_URL=//user:owd#host:port/dbname
And here my controller
public function xxx() {
$entityManager = $this->getDoctrine()->getConnection('test');
$sql = 'SELECT * FROM xxx.O2_ADRESSE WHERE ROWNUM = 1';
$stmt = $entityManager->prepare($sql);
$stmt->execute();
dump($stmt->fetchAll());
}
I get the following error :
An exception occurred in driver: ORA-12505: TNS:listener does not currently know of SID given in connect descriptor
Any help on what im doing wrong?
Are you sure that the db is running?
You can check it via sqlplus, eg:
sqlplus user:password#mysql:3306/pivot
Can you update DATABASE_URL and try?
to use oracle: DATABASE_URL="oci8://db_user:db_password#127.0.0.1:1521/db_name"
https://symfony.com/doc/current/doctrine.html
https://symfony.com/doc/current/bundles/DoctrineBundle/configuration.html#oracle-db
Took the config from elastic search documentation, and added it to elastic cloud yml.
xpack.notification.email.account:
ses_account:
smtp:
auth: true
starttls.enable: true
starttls.required: true
host: email-smtp.us-east-1.amazonaws.com
port: 587
user: <username>
password: <password>
giving me the below error:
'xpack.notification.email.account.ses_account.profile': is not allowed
How can I create a user in Influxdb using ansible module ?
In influxdb ansible docs , I could not find that how to create a user.
I am trying to create it via influxdb API, but have not got success in that.
- name: create user in influxdb
uri:
url: "http://localhost:8086/query"
method: POST
body: "--data-urlencode 'q=CREATE USER myuser WITH PASSWORD 'mypass' WITH ALL PRIVILEGES'"
body_format: raw
The response is,
fatal: [192.168.122.62]: FAILED! => {"changed": false, "connection": "close", "content": "{\"error\":\"missing required parameter \\\"q\\\"\"}\n", "content_length": "45", "content_type": "application/json", "date": "Wed, 05 Jul 2017 12:08:26 GMT", "failed": true, "json": {"error": "missing required parameter \"q\""}, "msg": "Status code was not [200]: HTTP Error 400: Bad Request", "redirected": false, "request_id": "a6c36bfd-617a-11e7-800c-000000000000", "status": 400, "url": "http://localhost:8086/query", "x_influxdb_version": "1.2.2"}
I had a nightmare with quotes... BUT this one worked for me:
- name: "[Centos7_InfluxDB] Create InfluxDB user"
command: 'influx -database {{item.database}} -execute "CREATE USER {{item.user}} WITH PASSWORD
{{item.pass}} WITH ALL PRIVILEGES"'
with_items:
- { database: "sample_database", user: "adminuser", pass: "'adminpass'" }
This code should work as you expect :
- name: create user in influxdb
uri:
url: "http://localhost:8086/query"
method: POST
body: "q=CREATE USER myuser WITH PASSWORD 'mypass' WITH ALL PRIVILEGES"
You can easily create a user using the command module.
- name: Create InfluxDB user
command: "influx -execute \"CREATE USER {{item.user}} WITH PASSWORD
'{{item.pass}}' WITH ALL PRIVILEGES\""
with_items:
- { user: 'admin', pass: 'admin' }
This should be a lot more efficient than using the REST api.
If anyone's wondering about that as well - just keep in mind that there are community modules for Ansible that already do everything you want, without having to do it with raw/command modules
Is there a simple way to debug why Doctrine is not connecting to MySQL?
config.yml has:
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
and parameters.yml seems to have the correct connection information in it. E.g.
parameters:
database_host: 127.0.0.1
database_port: null
database_name: <my database name>
database_user: <my database user>
database_password: <my database password>
However this piece of code still echoes out "Not connected".
$cnx = $this->getDoctrine()->getConnection();
if ($cnx->isConnected()){
echo "Connected";
}
else {
echo "Not connected";
}
and I'm not getting any errors returned.
Any suggestions?
This works:
$em = $this->getDoctrine()->getManager();
$em->getConnection()->connect();
$connected = $em->getConnection()->isConnected();
$connected will be true to indicate it is connected.
The connect() establishes the connection, and then isConnected() returns a boolean to tell if it is connected.
I'm trying to connect to my database on MySQL, with Sequel:
require "bundler"
Bundler.require
DB = Sequel.connect ({
adapter: "mysql2",
host: "localhost",
port: "3306",
user: "root#localhost",
password: "1234",
database: "sequel_demo"
})
I get this error:
C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mysql2-0.4.2-x64-mingw32/lib/mysql2/clien
t.rb:87:in `connect': Mysql2::Error: Access denied for user 'A2'#'localhost' (using password: YES) (Sequel::DatabaseConnectionError)
What is the problem?