We have a website based on Laravel 5.3 and a mobile app that can work offline. Laravel is using MySQL database.
I need to synchronize data between web and mobile app. Mobile app would make a request with a timestamp, and API would send all data changed since that timestamp.
My mobile developer said it would be easiest for him to receive the data as a single sqlite database file. So my question is:
is there a way in Laravel to export selected data to valid sqlite format?
sqlite format
Laravel got nothing to do with whatever your database server is. All you need to do is to dump your current database as pure SQL (i.e. using phpmyadmin) and import to sqlite database. If needed you can use tools like http://sqlitebrowser.org/ to import your dump and then hand your dev .sqlite binary file which shall work too.
I ended up by creating an Artisan command that dumps selected tables to sql and then converts it to sqlite using this script
So the whole code in my command looks like that:
exec('mysqldump -P ... login credentials ... tables to export ...'.storage_path('app/export/dump.sql'));
exec('mysql2sqlite '
. storage_path('app/export/dump.sql') . ' '
. storage_path('app/export/sqlite.db')
);
Related
In our backend project, we have some features that allows to export files to xlsx.
We have done some tests locally and everything is working fine.
However, I deployed the app in an Azure App Service and some of the exports (not all) are not working fine.
I deployed backend (PHP), frontend (React) and database (MySQL) in Azure. I copied the information of the local DB to the DB deployed in azure (just because we don't wanna waste time with the data).
In the backend project, we are using Laravel with Maatwebsite for the features related to the exports. I created a class that implements FromQuery, WithHeading and ShouldAutoSize and that has construct, query and headings functions. Next, in a Controller, I use this structure to get the file:
public function functionName(Request $request){
$fileName= 'name'.time().'.xlsx';
return (new ClassThatHasTheLogicOfExporting($request->all()))->download($fileName);
}
All my exports works like that, but I'm getting the following error in some of them:
"Excel cannot open the file because the file format or file extension is not valid"
When I try to open the file.
I've been reading about the issue and some people says that I should use ob_start() (at the beggining of the class) and ob_end_clean() (just before exporting the file) but when I do this, I get a 404 error in the web app.
A curious thing is that when I add a filter to the data for exporting (for instance, downloading only the data of people in a specific city) (I can do it in the frontend app), the file opens without errors.
With this strategy, I've achieved downloading all the data in separate groups, so I don't think that the issue is related to special characters in the data.
Does anybody have any suggestion?
I'm using maatwebsite/excel 3.1 and PHP 8 with Laravel 8
I believe the error statement correctly suggests the error is being caused due to an invalid extension. Don’t worry there are several workarounds to this, I am sharing them below:
Method 1 – Change the Default File Format to Save Excel Workbooks
In Excel 2007, click the ‘Microsoft Office’ button and then ‘Excel Options’. In Excel 2010 and higher versions, click File > Options.
Select the Export option.
Select the Change File Type option.
Change the file extension, and then click Save As.
Method 2 – Recover Unsaved Workbook
Go to File and select the Info option.
Under Manage Versions, select ‘Recover Unsaved Workbooks’ op
If MS Excel has unsaved files then, it will list them. You can open and save it.
Method 3 – Use the' Open and Repair' Feature of MS Excel
Open MS Excel application.
Go to File and select the Open option.
Select the corrupt file and choose the Open and Repair option.
You can also check this forum:
https://social.technet.microsoft.com/forums/office/en-US/63020ccc-51d7-46d9-b956-121c0e6efcc8/excel-file-error-the-file-format-and-extension-dont-match?forum=Office2016ITPro
Best Regards,
Steve
you can add the below
if (ob_get_length() == 0 ) {
ob_start();
$response = Excel::download(new KingdomsExport, 'kingdoms.xlsx',\Maatwebsite\Excel\Excel::XLSX);
return $response;
}
We have an Apex application (version 20.1) and our users must be able to change the database schema at runtime via button click (preferably without logging in again).
Currently we are solving this by installing our application multiple times, once per schema.
We recently discovered the function apex_export.get_application. We intend to use this function to bring our frontend under version control (finally!). We would like to deploy our application directly from the exported files. Having a single application, we would not have to mess with the internal component ids from the exported files.
Is it possible to install the application once and change the default schema via Pl/SQL code? Thank you!
I don't think this can be done, but perhaps the following is a reasonable compromise
add all the schemas you need to support to the workspace schema list
Any SQL (and I do mean any) in your app would be prefixed with an application item, eg
Before: select * from my_table
After: select * from &my_schema..my_table
At login time (or when a user selects it) you modify the MY_SCHEMA application item
(I've not tried this...so test/tread carefully)
I am new in Laravel and want to know such problem
I am running an web application on several server using Laravel.
But I have encountered with an issue.
When there is modification for the project, I need to sync with git on several servers.
But it has different settings for each server (eg: DB name, DB password...)
I have set it manually because I couldn't use .env or configuration file since the file is just pure php file.
The issue I want to solve is how can I get Laravel configuration data from pure PHP file(not controller or whatever).
It will be thankful if someone teach me solution.
You asked:
how can I get Laravel configuration data from pure PHP file
The answer would be this:
You just make some file in config/ folder of laravel app (or use the existing file like config/app.php)
You make an array of your key value pairs
<?php
return [
'some_key' => 'some_value',
...
and you simply call it with this code where ever you need it:
config('config_file.key');
for example
config('app.name');
would give you Laravel by default.
As you know, parse.com will be closed.
I made export of all collections.
Now i have the many dumps of collections.
Collections name like:
_User
AppParentCompany
It's normal tables name, but between this files i have relations, a relation contained in the next file:
_Join:parentCompanies:_User.json
Latest file name i understand like:
_Join - is relations
parentCompany - it's column
_User - a collection containing parentCompany column
Based on this, i have next questions:
How i can import this relations into a database?
What name will be for this collection of relation?
Thanks!
Take a look at this page: https://github.com/ParsePlatform/parse-server/wiki/Migrating-an-Existing-Parse-App
Prepare mongodb database connection string first.
Go to Parse your project's App Settings > General.
Find App Management > Migrate to external database. Press Migrate button.
Enter your database connection string, it will start with mongodb://...
Then press Begin the migration.
Then Parse will do the rest for you.
P.S. If you are using mongolab, go the web browser, into your database, then you can find _Join:xxx:xxx, _SCHEMA and more in Collections.
Is there any tool which could dump export whole db (structure +data), save the bd_sql.zip on server & return url for download the dp dump?
I found LazyDbBackup but it is cron type plugin and I need to allow admin to just a button for db dump when he require.
Good I got it DataSafe !
It the plugin which I was searching.. :)