Prestashop 1.7: Can I use another database just for executing a side script? - prestashop

I have created a Prestashop website with a database N°1. For some reasons, I want to write a script, that I'll execute a few times and that will simply fill a database N°2 with some data. This script has nothing to do with my Prestashop website, but is part of the same project and then, must be hosted in the same server, and moreover must be present within the Prestashop website's files (under a module directory I've made).
My question is: is it possible to use this database N°2 (only for this script)? Can I use Prestashop's Db.php class to do it?
Don't hesitate to ask for more informations if I'm not clear.

So if i am reading your post correctly you want to create two databases.
For example "prestashop_n1" and "prestashop_n2".
prestashop_n1 contains all prestashop required tables.
prestashop_n2 contains data extracted from prestashop_n1
In order to extracted data from prestashop_n1 to prestashop_n2 you could write a module.
In this module you can create a database connection to database prestashop_n2
You can use PHP to copy data from prestashop_n1 to prestashop_n2
Alternative you can add a cron-job to execute your script for copying data x times a day.

Related

Odoo v10 HR payroll community version

Hello guys i am working on odooV10 community version. I have installed my own module for HR payroll and leave management with a DB consisting of records. My question is MY created module wants to install on another machine. How can i achieve that.??? is that database entries stored in the same module folder???
I hope someone can clear my doubt..
for more clarity:
I will install payroll in my system
edit all entries as i want
copying this payroll module in another machine
These are the steps that i planning to do.
Are you wanting to have a set of default records that always install with your module?
If so, you want to load these into a data file that will make these a permanent part of your module.
You can read about data files in the documentation and/or review how Odoo does this in the core code.
If you're only needing to get the records into another database, you can Export from the first database and Import into the next.
You have several options, you must choose the one that best fits your situation:
If you want to pass information from one database to another you can use the export option of odoo:
1) Go to the tree view of the model you want to export and select the record (s).
2) Expand the More option and click on Export.
3) Select the fields you want to export and save the csv file that will be used to import.
To import: you must go to the tree view and select the Import button that should appear next to the Create option and follow the steps indicated.
If you want to keep the data in your modules to be created every time you install you must create data.xml files
You can export the database directly. You can visit this page to know the steps to do it from odoo
Create-backup
I hope I've helped

how to display the result of a procedure running from the server side in oracle?

I am trying to automate a daily monitoring activity where there are set of scripts to be executed(all are select statements). I am in the process of creating a procedure which runs these scripts and by means of scheduler, this will be running daily once. My problem is since these activities are taking place in server side(server backbone), How do i save the results? Earlier we will run all the scripts manually and save it in a notepad. Is there any option to do the same in automation? Like saving in our PC or SQL developer? Instead of logging in to server and searching the path where the file is saved? I thought of saving the results in a table but i am looking for a better option.Please suggest...
Generally it is a good idea to save the results in a table as this gives you flexibility when querying the results or exporting them in multiple formats.
There are multiple options to get the data to the client:
Query the table with the results from the client
Generate a HTML from the results table and have make it accessible from a HTTP server.
You can also create a web PL/SQL package and generate the HTML within (http://docs.oracle.com/cd/B28359_01/appdev.111/b28424/adfns_web.htm#i1006207)
Export the data from the results table to a file and put it in a shared directory that is accessible by the client.
Email the results from the PL/SQL package.
I thought of saving the results in a table but i am looking for a better option.
What is exactly the issue with the "table" option?
Regarding "saving in our PC or SQL developer": one problem with that is that a PC/app screen is:
a PC is usually less resilient to reboots, crashes, etc.
it's intended for private use. Unless you're working alone - these logs may be of interest to other people;
..
Other options: it can be made to send e-mail; copy the file to a well known place (incl. one which is directly mounted on your PC); write to database table (as already suggested); and more.

Wordpress SQL dump to restore sample data on new sites

I have set up a wordpress site, installed a theme, imported the sample data xml file, and did a sqldump of the database after completing these steps. I have a script that will automate the creation of the wordpress directory and database for a new site. I would like to add restoring the new database with the dump file. I have been able to do this but the links to wp-admin and wp-login point to the old site's directory instead of the new one. Any idea of why this may be and what can be done to avoid this?
I found the problem. The sql dump simply had all the data including the absolute links that were generated. So I used perl to search for the strings I needed to update in the sql dump before I put the data into the new database. Thanks.

Creating a local SQL database file?

Please note:
I am a game programmer, so backend development isn't my forte. There are times, however, where I work with our database at my job. Please don't shoot me if my question is ridiculous.
Is there a way to create a local mySQL file and access it through PHP or C#?
I know you can make a local webpage on your machine (pretty much for testing purposes) and access multiple locally created files.
I assume that something similar would work with mySQL. (Are the login credentials also stored within the file?) I remember seeing a few online tutorials where it offered a download for both PHP and the database file, but I can't seem to find them now.
I've searched for this, but all the relevant results involved downloading mySQL and hosting a server which is a bit more than I wanted to do.
So if its possible to create a local mySQL, how do you do so?
The tools I intend on using while doing this:
PHP/JQUERY/HTML and C#
For MyISAM tables, inside the MySQL data directory there is one directory per database which contains several (usually three) files per table. For InnoDB tables, they are all contained in several files directly inside the data directory.
The location of the MySQL data directory is usually set in my.cnf using the datadir parameter.
The login credentials are stored in a special database called "mysql" which is in that data directory like any other database.
However, you have to install and run MySQL to access those files. You cannot access them with PHP or any other client API alone. If you want to do such a thing, better use SQLite.
MySQL is a database engine, u need to install that before you can use it. Unlike SQLite which stores it's database in files. Maybe that is something more of your liking. And I know there are library that supports SQLite for PHP, not sure about the rest.
SQLite you don't need to install anything.
MySQL can be used an an embedded database, but you will need to contact them in order to purchase a copy of it.

SQL table not created when deploying a WAR file to Liferay

I've created a JSR-268 portlet for Liferay which uses services to interact with a database. I can deploy the portlet without problems or errors, but the table defined by the services is not created!
I get no "table not found" error when I test the portlet. I get no errors at all! The table just isn't there in the database. I've found other things on the internet saying that I should use the generated "create.sql" file that the Liferay Service Builder created, but I don't see that file anywhere.
Can someone help me out?
Have the tables never been created? I had a similar problem when I deleted the tables by hand. I thought they would be created again when deploying the portlet again, but it didn't happen.
After studying the source code I found out that Liferay stores information about the portlets in the table servicecomponent and checks 2 things before it executes the (pseudo) SQL in META-INF/tables.sql:
The build.number in service.properties must be higher than that, stored in servicecomponent,
The tables.sql must be different from the one stored in servicecomponent.
Only then the tables.sql is executed.
An easy way to achieve that, is to delete all entries in servicecomponent addressing your portlet.
Try by deleting an entry from servicecomponent table. And redeploy your portlet.
delete FROM servicecomponent where buildNamespace="<your table namespace>"
I have faced the same problem and below given solution works for me.
Steps
I have changed the build.number in service.properties higher than that stored in servicecomponent.
Removed all the xml files from META-INF folder.
Removed all the sql files from webapp/WEB-INF/sql folder.
Then build-service and deploy will creates custom tables that are defiend in service.xml file.
If you're using serviceBuilder in Liferay 6.2 when you define a new entity in the Liferay schema in service.xml, the first time that any Portlet tries to access the table it will be created if it's not exist.
There are several problems when you're using a different schema because sometimes Liferay not create tables automatically. Then you need to lauch the Creation SQL sentence and create it manually and then access it through LocalServiceUtil.