PDO issue in Laravel 4 when using an artisan command - pdo

I am trying to build a artisan command that will connect to a remote MSSQL server, retrieve some records and store them in the local MySQL db.
The query I am performing is DB::connection('sqlsrv')->select('SELECT * FROM Users')
If I use the above in a blade view, it works. But if I use it in an artisan command, I get the error [PDOException] could not find driver
Any help appreciated

Related

How to create sh script which will run SQL file on CentOS without sqlplus lib

I'd need to create a sh script, which will connect to Oracle DB and then execute a SQL file.
The problem is that sqlplus is not installed on that Cent-OS machine and most probably it won't be installed either.
Is there a way how to do this?
You can easily install Oracle Instant Client including sqlplus executable ("Free to download, deploy and distribute").
See
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
If some java version is installed on the server, you can create a simple class that will connect to oracle DB via JDBC, load the sql script and execute it.
Create and compile java class
Upload class file, sql script + oracle_driver (jar file) (https://www.oracle.com/database/technologies/jdbcdriver-ucp-downloads.html)
Execute the java program
You can’t. You need to install oracle client which include sqlplus or sqlloader.
Or you can use Python and library Cx_Oracle, but you still need sqlclient to connect to database.
If you don’t want to install oracle client, you can use external table to load data to database or some etl tool.

Importing sample database into phpMyAdmin

I am trying to import a sample database "employees.sql" from official phpMyAdmin webpage. I am using uwamp server and getting the following error when using phpMyAdmin "import" option:
Unrecognized statement type. (near "source" at position 0)
.SQL FILE AT LINE WHERE ERROR IS REPORTED:
SELECT 'LOADING departments' as 'INFO';
source load_departments.dump ;
I am not sure what to change to successfully import the database. I also tried different things like putting load_departments.dump in quotes, but it still didn't work.
How do you use MySQL's source command to import large files in windows
must read and you will definitely get many ideas!
I think you should fire source command from cmd (command prompt)
I suggest you to create an empty database and import that sql file inside of it. Check it out..
Assumption: MySQL Server was installed and you have downloaded the employees database from github. Unzip the package and go to the directory from command prompt.
Enter the following command and on prompt, provide the sql password.
mysql -u root -p -t < employees.sql
Verify your installation by entering the following command.
mysql -u root -p -t < test_employees_md5.sql

Get error in Lumen database migration after delete migration file manually

Below is the step that I followed.
php artisan migrate:install
php artisan make:migration create_categories_table --create=categories
So it's create migration table in database.
it's create 2016_11_24_054214_create_categories_table.php file in database/migrations folder with some basic stuff. I have added my columns information and run next command php artisan migrate so my table is created successfully.
Now I have deleted 2016_11_24_054214_create_categories_table.php file manually and delete categories table from database then I tried to create same categories table using same last command php artisan make:migration create_categories_table --create=categories but it's give me a below error.
[ErrorException]
include(/var/www/news_reporting/vendor/composer/../../database/migrations/2016_11_24_054214_create_categories_table.php): failed to open stream: No such file or directory
I googled and found one solution that run php composer dump-autoload command but this command give me below error.
Could not open input file: composer
I am using linux.
Could not open input file: composer
Please make sure that composer is installed in your system.
To check just go to terminal and write command composer if it is installed then you will see some stuff else you will get composer not found error
If above is a issue then you need to install composer in your system user this link for installing reference.
Or you might need to run php artisan migrate command for migrating migrations.
you don't need to precede composer with PHP command, try it this way:
composer dump-autoload
and that should solve your migration problem.

Run sql file for a specific derby database

Using the ij tool and Apache Derby, is it possible to execute an sql file in a single command line?
In other words, is it possible to supply the connection string to ij?
At the moment I'm doing it with several steps:
java org.apache.derby.tools.ij
connect 'jdbc:derby://someserver:1527//databases/timesheets';
run 'my_file.sql';
It is possible to run ij using properties, see examples here.
Use the following command:
java -Dij.database="jdbc:derby://someserver:1527//databases/timesheets" org.apache.derby.tools.ij my_file.sql

SQL error in Laravel when moving project between machines

I just moved my laravel project from one machine to another.
What I didn was:
-Create a new Laravel Homestead machine.
-Copy all files from my laravel app's folder
The website serves ok from my new machine but any database dependant operation fails because the tables aren't created in my new server. The error is the following:
QueryException in Connection.php line 673: SQLSTATE[42S02]: Base table or view not found:
The migrations are present in my new machine but I cant do a
php artisan migrate
or a
php artisan migrate:refresh
since both return
[Symfony\Component\Debug\Exception\FatalErrorException]
Cannot declare class CreateUsersTable, because the name is already in use
I've spent so much time here I don't know what to do.
delete all the tables from the database manually including the migrations table and run php artisan migrate