Wordpress SQL dump to restore sample data on new sites - sql

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.

Related

How to Upload .xls Files into Oracle DB using PL/SQL only

I'm fairly new to using DBs and have been tasked to create an automated process that uploads Excel-Files into a Oracle Database.
I was told that the User should put the files into a dedicated folder and then a process should automatically upload the files. After checking Stackoverflow and the Internet, however it looks to me like there is no way to do the upload with just PL/SQL.
Do i need to use other external tools to achive this or am i just looking the wrong way?
The reason i want to do it with just PL/SQL is that i don't have sys rights on the server or a way to install any tools right now.
You can upload CSV files stored in a folder using SQL Loader directly into Oracle Tables. But you need to have those files stored as CSV not XLS and transfer them to a folder in a server which contains at least an Oracle client. In this case, your user should save the files as csv, and then you must have a pick up process to move them to a server where you can run the sql loader process.
However, if you want to keep using Excel, and you have no option to move the files, Oracle Application Express which is free and included with Oracle Database contains a plugin to upload directly and automatically excel files into tables. You would have to create a small application in Apex with a page for doing this. It is totally out-of-the-box and quite easy. If you use Apex 18c or higher, it is there. If you use Apex 5.1.4 you need to install a plugin. In this case, the user is responsible to upload the excel file by the web apex application, or you can use the API APEX_DATA_PARSER package for doing so without manual intervention. However, keep in mind that if you use the API, you need to have the files accessible for the database.
Apex Data Parser 19c
Let me know if you have more doubts about it.
Regards

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

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.

What is the correct way of storing .sql type files in a database?

I am working in a system which gets reloaded frequently. When the system is reloaded a lot of files can be deleted or changed back to a previous stable build version (it's a dev environment). The only thing that doesn't get reloaded is a database.
I have been tasked with inserting and deleting .sql scripts into the environments so that if required someone can run them at a given time. Usually 2 weeks after the files have been added to the system.
Initially I had thought of creating a directory to keep the files, and make a table where one of the columns keeps the path to these .sql files. This would allow for someone to query the database and using the path they could execute a desired script. The problem is the environment constantly reloading which could result in losing files.
Am I correct in assuming that the correct way to approach this is to use BLOB datatype to store the .sql files? The database isn't reloaded so no files would be lost. I am new to SQL and I'm unsure what is the correct approach to this. Would Varchar also work? Is one datatype more efficient than the other?
I wouldn't put SQL scripts in a SQL database, it doesn't feel right.
Sql Scripts usually go in a git repo, in order to be versioned and have better visibility.

How to restore specific datebase from total SQL backup?

I'm moving a website and I backed up all of my databases from the old host into one total sql backup file.
I need to restore a specific database inside this file to my new host that is used for the wordpress site.
How would I achieve this?
cheers
Open SQL File using a Text editor then search for the specific database, in my case there was a comment declaring where it began. Then copy all the tables into a seperate file with extension .sql

How do I assign a URL to a file stored in a SQL database?

I have a self-made document management system that stores files of all sorts in an SQL database. The database stores 4 basic rows of information, namely:
FileID
FileName
FileSize
FileType
FileContent
I want to use viewer.JS to preview files, but it requires that I have a URL to access my file, and I have no idea how to assign a URL that would access a file of my choice in a row in a database. I'm building on a home-grown PAAS, thats built on .net.
I've heard that the URL rewrite module for IIS (I'm on 7) may solve my problem, but cant seem to crack it.
Any help on my problem would be much appreciated.
IMHO IIS rewrite would not help you. Assuming you're using .net, you'd need to build a simple website and use routing in a view.
The url could be something like /Document/{fileid}. when this path is encountered, the router would call your view and you can return the file's content.
Store file in SQL Server database using .Net MVC3 with Entity Framework has some info on a model/controller.
Note: There are some security issues with this approach.