Django postgres database not connecting with Lumen - php

I am trying to connect django.db.backends.postgresql with my lumen application. But when I run the query then following error occured
could not find driver
Even I change the driver type from mysql to pgsql
My database connection
'ml_db' => [
'driver' => 'django.db.backends.postgresql',
'host' => env('ML_DB_HOST'),
'port' => env('ML_DB_PORT'),
'database' => env('ML_DB_NAME'),
'username' => env('ML_DB_USER'),
'password' => env('ML_DB_PASS'),
'charset' => env('DB_CHARSET', 'utf8mb4'),
'collation' => env('DB_COLLATION', 'utf8mb4_general_ci'),
'prefix' => '',
'timezone' => env('DB_TIMEZONE', '+00:00'),
'strict' => false,
],
Is there any way to connect this database with my lumen application because I am using multiple databases in application.

The obvious answer here is, that you haven't installed the corresponding driver for your used dbms. So just install it.

from your configuration posted in the question, I assume that it's your lumen configuration. There is no 'django.db.backends.postgresql' driver in lumen. What we have is pgsql driver unless you create such a custom driver yourself,(which I assume is not the case).
so change the driver parameter to the following?
'driver' => 'pgsql',

Lumen .env file:
DB_CONNECTION=pgsql
DB_HOST=your host
DB_PORT=5432
DB_DATABASE=database
DB_USERNAME=username
DB_PASSWORD=password
The link

Related

Could not connect to Sybase Central DB via Laravel 5.7

I just installed Laravel 5.7 on my windows 7 machine and I want to use Sybase Central (v6.1) as my database but I can not seem to figure out how to connect to it.
I did a lot of google search but there is not much information out there when it comes to Sybase. This is what I'm trying but it does not work.
'connections' => [
'sybase' => [
'driver' => 'odbc',
'host' => env('DB_HOST', 'host-name'),
'port' => env('DB_PORT', 'port-number'),
'database' => env('DB_DATABASE', 'db-name'),
'username' => env('DB_USERNAME', 'user'),
'password' => env('DB_PASSWORD', 'password'),
'charset' => 'utf8',
'prefix' => '',
]
]
The error I get
InvalidArgumentException: Unsupported driver [odbc] in \vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php:283 Stack trace: #0
Does Laravel support Sybase or not?
Out of the box, Laravel doesn't look to support odbc, but there seems to be a package you can install to support it available at ODBC integration for Laravel Framework.
Simply follow the installation and usage guides on the page, and you should be able to use "driver" => "odbc" without issue.
From terminal run
composer require abram/laravel-odbc
Then configure the following files:
config/database.php
"connections" => [
"sybase" => [
"driver" => "odbc",
...
]
]
config/app.php
"providers" => [
...
Abram\Odbc\ODBCServiceProvider::class
]

Oci8Exception in Oci8.php line 466

Attempting to connect to an Oracle database with yajra/laravel-oci8, below is the configuration. Note that I've also installed the instant client 11g corresponding to the bit version of Windows Server. I've ensured that the 11g ext is enabled in the php.ini.
Spent 4 days on this now, does anybody have any idea what's going on?
I don't even get an error message, just a stack dump which is attached.
'oracle' => [
'driver' => 'oracle',
'tns' => 'LISTENER',
'host' => '192.168.39.73',
'port' => env('DB_PORT', '1521'),
'database' => 'QORA',
'username' => 'ETEST',
'password' => 'ETEST',
'charset' => env('DB_CHARSET', 'AL32UTF8'),
'prefix' => env('DB_PREFIX', ''),
'prefix_schema' => env('DB_SCHEMA_PREFIX', ''),
],
Your error messages are showing you are trying to connect on port 3306, which is the standard MySQL port. According to your config, you're looking at the DB_PORT value from the .env file, with a backup of 1521 if that doesn't exist.
My guess is that your .env file has the following line:
DB_PORT=3306
You either need to comment or remove that line, or change 3306 to 1521.

Laravel PHPUnit PDOException exception

I don't know why when I run a PHPUnit test, I get the following error:
PDOException: SQLSTATE[HY000] [2002] No such file or directory
My testing environment database setting is:
return [
'fetch' => PDO::FETCH_CLASS,
'default' => 'mysql',
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'clg_test',
'username' => 'root',
'password' => 'veryHardPass',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]
],
'migrations' => 'migrations',
];
The reason why I am using MySQL as oppose to SQLite is because my migration files use dropColumn which is not supported by SQLite. I call the migration via Artisan::call('migrate') in the setup.
If I actually call migration manually in the terminal via php artisan migrate --env=testing then the migration IS successful and the databases are created.
Why am I then facing the above problem?
Try changing localhost to 127.0.0.1. The message you're getting is indicative of the script not being able to connect to MySQL through a socket, but using an ip should work.

Laravel Artisan Migrate connection refused

My website works, its clearly accessing the database. I can log in and i can create records, etc...
Ive created a new migration, and I'm trying to insert it, but when i run
php artisan migrate
i get the error
[PDOException]
SQLSTATE[HY000] [2002] Connection Refused
My database config has the passwords hidden in the environment so my config looks like this
'mysql' => array(
'driver' => 'mysql',
'host' => getenv('DB_HOSTNAME'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USERNAME'),
'password' => getenv('DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
my environment variables are loading correctly. What am i missing?
I figured it out. Apparently the environment that artisan was seeing was different from the environment i wanted it to see, so it was using the wrong host
php artisan migrate --env=production

Laravel setup of migrations using Artisan is failing

I am trying to set up migrations for the first time and when I run
php artisan migrate:install
from within the root folder of my project I get the following SQLSTATE error:
SQLSTATE[HY000] [2002] No such file or directory
I have tested running mysql to make sure it is working and referenced and I have ran php artisan help:commands to make sure artisan is working (it is).
The website itself is functioning and reading from the database fine.
This may be an issue with the sockets if you're using MAMP or XAMPP.
From http://forums.laravel.io/viewtopic.php?id=980...
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
'database' => 'database',
'username' => 'user',
'password' => 'pass',
'charset' => 'utf8',
'prefix' => '',
),
),
You can pass an optional "unix_socket" to the array and specify the MAMP socket instead of the default location.
Also, try and change 'host' => 'localhost', to 'host'=> '127.0.0.1', because unix does not recognise 'localhost'

Categories