How to transfer favorites tree items from one db to another in HeidiSQL? - transfer

I'm trying to transfer favorites tree items from one database to a new one. Sometimes I have to import a database from my production environment into my local environment, and I have to name it differently (e.g. DB-0028) to keep my local database (DB-0024). Then I want to have marked favorites tree items in the new database which are the same as in the previous database.
favorites tree items in local database
I tried to edit HeidiSQL settings file, but with no luck. Maybe you know better way to do that? Thanks for any tip!

You need to
create an empty database in your local server
select the wanted tables in the "Database" tab (not in the tree)
rightclick, then click "Export database as SQL"
Then, in the upcoming dialog:
in the "Output" dropdown, select your local server
in the "Database" dropdown, select the empty database you created in the first step

Related

How to transfer data from one database to another in Django?

I am recreating a web app in Django that was running in a server but it was terminated, fortunately, I did a backup of all the code. My problem comes with the database because but I do not know how to transfer all the data from the old db.sqlite3 Django database web app into the new one.
I found a similar question as mine Django: transfer data from one database to another but the user wanted to transfer data from specific columns because their models.pyfrom the old and new databases were slightly different. In my case, my models.py from the old and new databases are the same.
Alternatives
I am using the DB Browser for SQLite to explore the content of the old database and I could add manually each row into the Django administration but this will take me too much time.
I could copy the old db.sqlite and replace it in the new web app because the models.py file remains the same but this solution is not appropriate IMO, this solution is rude and I think it goes against the good practices of Software.
How should I proceed for transferring data from the old database to the new one?
This seems like a one time copy of one db to another. I don't see how this goes against good software practice unless you have to be copying this db frequently. I've done it before when migrating servers and it doesn't cause any issues assuming the two instances of the application are the same build.
I was able to do some minor tricks in order to solve my problem because there is not a straightforward functionality that allows you to transfer all your data from two sqlite databases in Django. Here is the trick I did:
Download the sqlite db browser to explore and export the contents of your old database in a .csv file. Open you database with sqlite db browser and hit on the tables option and you will see all your tables, then do a right click on any of those and hit the export as a csv file option to generate the csv file (name_of_your_csv_file.csv). The other alternative is to use the sqlite3.exe to open your database in cmd or powershell and then doing the export with:
.tables #this lets you explore your available tables
headers on
mode csv
output name_of_your_csv_file.csv
2.There are two choices up to this point: You can either insert all the records at once to your new database or you can drop your existing tables from the new database and then recreate them and import the .csv file. I went for the drop option because there were more than 100 records to migrate.
# sqlite3
# check the structure of your table so you can re-create it
.schema <table_name>
#the result might be something like CREATE TABLE IF NOT EXISTS "web_app_navigator_table" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "ticket" varchar(120) NOT NULL);
#drop the table
drop table web_app_navigator_table
#re-create the table
create table web_app_navigator_table(id integer not null primary key autoincrement, ticket varchar(120) not null);
#do the import of the csv file
.import C:/Users/a/PycharmProjects/apps/navigator/name_of_your_csv_file.csv table_name_goes_here
You might see an error such as csv:1: INSERT failed datatype mismatch but this indicates that the first row of your csv file was not inserted because it contains the headers of the exported data from your old database.

sitecore publish item from web to master

I am working with Sitecore Intranet Portal. I am using web database for CD.
If a user change his email Id. How would I publish this to master database.
I am using this code to publish item from web to master db.
// The publishOptions determine the source and target database,
// the publish mode and language, and the publish date
var publishOptions =
new PublishOptions(Database.GetDatabase("web"), Database.GetDatabase("master"),
PublishMode.SingleItem,
item.Language,
DateTime.Now);
var publisher = new Publisher(publishOptions);
// Choose where to publish from
publisher.Options.RootItem = item;
// Publish children as well?
publisher.Options.Deep = true;
// Do the publish!
publisher.Publish();
It would be nice to know the correct procedure.
To publish from web to master is a bad practice.
This kind of content is named User Generated Content. I suggested to use this approach :
https://sitecore.unic.com/2015/07/16/user-generated-content-in-a-security-hardened-environment
Or you can use webservices. This allows all content (even user-generated) to be authored in your CM instance. This allows you to leverage the capabilities of the platform for workflow, publishing, etc.
Either use an external database or use Sitecore users for a certain domain and store everything in the core database. The core database is commonly shared between all environments
You can make use of package to transfer your item from web to master. You can follow the following steps:
Create your item package from web.
Use the tool that i have developed to convert the destination of the items. That is, change from web to master. The tool is found on marketplace at Sitecore package modifier.
Install the modified package on the master database.
Another solution is to have a schedule job that create the package from web, modified it and install it on the master database. This hence require no manual intervention.
I prefer to use this method than the sitecore transfer method because the transfer method tends to timeout or cause an error if there are lots of items to transfer.
The best practice to store the user information in the Core database. Sitecore is using ASP.NET membership to manage the user accounts. I recommend you to store all the user info in the core DB.
Sitecore doesn't provide any option to publish data from web to master, however, it has provides you an option to transfer data from web DB to master DB.
Check out my blog Transfer Items from Web to Master Database for complete details on transferring the data from one DB to another DB
Step 1: Login to Sitecore desktop mode.
Step 2: Select the source database from where you need to transfer the items. If you want to transfer from Web to Master then select Web Database in the right-hand bottom corner.
Step 3: Open the content editor and select the item which you would like to transfer.
Step 4: Right click on the Item and select Copying>>Transfer and click on the transfer button
Step 5: In the Transfer window verify if the source item is selected properly or not.
Step 6: Click on Next to continue. In this window first thing is to select the destination database to which you need to transfer. The second thing is to select the parent item or the destination folder where you need to place this item. In my case, I need to select Layout because sublayouts are present in the layouts item.
Step 7: Click on next, here you will get an option which says include subitems. Select the checkbox if you need to restore the subitems also else uncheck the box to transfer only the selected item.
Step 8: Click on transfer button and it will start the transfer process. Close the dialog box once the transfer is completed.

sitecore: Serialization and package designer

I have a large amount of data(content created by user, not developer) created in Sitecore.
I know that in order to transfer large amount of data from one environment to another, I need to serialize all the content first.
My question is, after I serialize the content, do I need to create a designer package that contains the data I want to move? Or after I serialize, I use the serialized file?
Serialization is an option, but you could also create a package through the Package designer, download it and install it on the other environment.
If you are installing big packages, it is a good practice to set the value of Indexing.UpdateInterval in the web.config to 00:00:00 to prevent starting the Lucene indexer during the package install which results in much longer install times.
You don't need to create a package, use the serliazied file and update via the UI as below.
To update an item from the text file:
In the Content Editor, select the item that you want to update.
On the Developer tab, in the Serialize group, click Update Item.
To update an item with all its subitems from the file system:
In the Content Editor, select the parent item that you want to update with all its subitems.
On the Developer tab, in the Serialize group, click Update Tree.
To update the whole database:
In the Content Editor, select any item.
On the Developer tab, in the Serialize group, click Update Database
You can also use the "Transfer Item to Another Database" feature.
Just select the database where you want to go, go to Control Panel, Database, Transfer Item to Another Database.
This will open a wizard. Then you can select the Source items (the items you want to transfer to another database), then select the Target database and select where you want the items to be in the tree (i.e. under Home or some other node).
For some more information you can go to this blogpost by Sam J. Griffin, which explains it step by step.
One very important side-note though - don't copy the /sitecore/templates/sytem if you want to do all templates. This will result in some circular reference issues. If it's just content that you're copying it should be fine.
If you have a spare $149 then you should also take a look at the new Sitecore synchronization tool from Hedgehog:
http://www.hhogdev.com/Products/Razl.aspx

cleaning django db of previous tables

I had a table in Postgres called user that was a custom model. I then switched over to the default Django User class, but there have been issues because of the name overlap. How can I either wipe the previous table, or wipe the entire DB (still in testing, so not a big deal) to start over?
The simplest would be to execute a DROP TABLE statement directly in your database prompt, remember that Django models are just like any other table for your database
dropdb --help
Run this in the terminal

Is it possible to include a database view in a JPA/EclipseLink CriteriaQuery?

I am working on a project that needs to be able to create dynamic queries into an H2 database. This also includes a full text search with built-in H2 logic, tables, and triggers.
I have been trying to figure out how to add that full-text search into my CriteriaQuery but keep running into the road block that the tables used aren't entities in my model. I could add them as entities, but I don't want them created automatically by EclipseLink when a new database file is created since there is a function in H2 that creates the tables and does other necessary housekeeping.
I had tried the path of creating a view to query the full text tables to give me the information I need in the format I need. But I still keep running into the same problem that that view is not an Entity.
Has anyone encountered this situation before and/or figured out a way around it?
Thanks!