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
]
Related
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
I'm trying to connect Laravel with a multiple sqlserver databases, I defined the connections on my database.php file correctly :
'connections' => [
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '16000'),
'database' => env('DB_DATABASE', 'dbname'),
'username' => env('DB_USERNAME', 'me'),
'password' => env('DB_PASSWORD', 'me'),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
'sqlsrv2' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '16000'),
'database' => env('DB_DATABASE_2', 'dbname2'),
'username' => env('DB_USERNAME', 'me'),
'password' => env('DB_PASSWORD', 'me'),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
],
and set my .env file
DB_CONNECTION=sqlsrv
DB_HOST=127.0.0.1
DB_PORT=16000
DB_DATABASE=dbname
DB_USERNAME=me
DB_PASSWORD=me
I try to verify the connectivity to my sql server database from another application and it's working perfectly. then I created a model on my laravel application and once I type php artisan migrate I get this error :
anyone can help to resolve this problem ?
UPDATE !
After adding pdo sqlsrv extensions to my ext folder and my php.ini i get this error :
[![enter image description here][2]][2]
[![enter image description here][3]][3]
UPDATE 3 :
After installing odbc 13 i got this problem
Ah, WAMPServer has 2 seperate php.ini files.
One is used by PHP under Apache and the other by the PHP CLI.
I see you are using the CLI, so you need to check that you have included the SQL Server drivers extension in the CLI php.ini file.
You will find that in:
C:\wamp64\bin\php\php{version}\php.ini
You have to edit this manually, there is no menu link to do this, the menu link to edit the php.ini only edits the PHP under Apache version of php.ini
Make sure you edit the php.ini file in the folder that matches the version of PHP you are actually using for this project, as of course you can have multiple versions of PHP installed under WAMPServer
UPDATE: Second Problem
You have added the 32bit AND 64 bit SQL Server drivers to your ext folder!
Your WAMPServer menu shows
1. php_sqlsrv_72_ts_x64
2. php_sqlsrv_72_ts_x32
3. php_pdo_sqlsrv_72_ts_x64
4. php__pdo_sqlsrv_72_ts_x32
as you are using 64 bit wamp, you should only have these 2
1. php_sqlsrv_72_ts_x64
2. php_pdo_sqlsrv_72_ts_x64
I'm using laravel 5.2 with mongodb.
firstly I have created the laravel project using the command
composer create-project --prefer-dist laravel/laravel NC_Data
Then I have install the latest version of the mongodb package using the composer like:
composer require jenssegers/mongodb
Added the below line in config/app.php, in providers array:
Jenssegers\Mongodb\MongodbServiceProvider::class
and in the aliases array:
'Moloquent' => 'Jenssegers\Mongodb\Model'
below is the connections array in app/config/database.php, :
'mongodb' => array(
'driver' => 'mongodb',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', 27017),
'database' => env('DB_DATABASE', 'dbname'),
'username' => env('DB_USERNAME', 'username'),
'password' => env('DB_PASSWORD', 'password'),
'options' => array(
'db' => 'admin' // sets the authentication database required by
mongo 3)
),
Also changed the default DB_Connection:
'default' => env('DB_CONNECTION', 'mongodb'),
When I run my project using CLI command of laravel i.e php artisan serve.It will run on port 8000 i.e http://localhost:8000/listing it works perfectly.But When try to run it using http://localhost/NC_Data/listing. NC_Data is my project folder,it gives me the below error:
FatalThrowableError in Connection.php line 149:
Class 'MongoClient' not found.
Can anybody please help me with this. Thanks in advance.
I am getting this error:
MongoDB\Driver\Exception\InvalidArgumentException: Failed to parse MongoDB URI: 'mongodb://mongo:tcp://172.17.0.3:27017/mydatabase' in /var/www/laravel/vendor/mongodb/mongodb/src/Client.php:81
My enviroment variables look like this:
MONGO_DATABASE="mydatabase"
MONGO_HOST="mongo"
MONGO_PASSWORD=""
MONGO_PORT="27017"
MONGO_USERNAME=""
and my database.php looks like this
'mongodb' => [
'driver' => 'mongodb',
'host' => env('MONGO_HOST', 'localhost'),
'port' => env('MONGO_PORT', 27017),
'database' => env('MONGO_DATABASE', 'mydatabase'),
'username' => env('MONGO_USERNAME', ''),
'password' => env('MONGO_PASSWORD', ''),
'options' => [
'database' => 'admin' // sets the authentication database required by mongo 3
]
I can correctly ping mongo from the container and it resolves to 172.17.0.3 as per the connection string. It seems as if the rest of the connection string is not getting generated correct?
I am running Laravel 5.2 and my package.json has this entry
"mongodb/mongodb": "^1.0.0",
"jenssegers/mongodb": "3.0.*",
As per https://github.com/jenssegers/laravel-mongodb 3.0.X is highest compatibility for Laravel 5.2.
Many thanks in advance
After further investigation my link from Amazon ECS was passing another MONGO_PORT which was overriding the env set in my .env file.
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.