Take data from an XML file and put it into a MySQL database - mysql

I'm looking to construct a script that would go through an XML file. Would find specific tags in it, put them in a table and fill the table with specific tags within them. I'm using MySQL 5.1 so loadXML isn't an option and I think that ExtractData() method wont be much use either.. but I don't really know. What would be the best way to go about this?
edit// I know how to do all of this in C except the creating the new tables in a database, how would I do that in C?

Per your edit, using the MySQL client library, you would just use mysql_query() with the standard CREATE TABLE syntax.
I'm not quite sure why you are doing it the way you are doing it, but I'm not working on whatever you are working on :)

Have a look at this blog. It will explain you how to do this using ExtraceValue() and also look at XML Functions.

Related

amnah/yii2-user use own database instead of the migrated one

Hiii,
I'm starting to get familair with Yii 2.
What i'm trying to do is instead of using the migrated database, use my own database.
Can someone tell me the best way to do that and where i should be looking.
I'm using the basic template.
Thanks in advance.
I do not recommend doing it this way because you will lose compatibility with other features and also when there are updates. It is wise to use the MIGRATIONS to generate the correct structure.
In any case, if you really want to change, you have q to do this in the way: vendor\amnah\yii2-user\models or extends it.

Slick Code Generator Not Including Schema With Table

I have two db schemas on the same server for MySQL. I want to be able to join tables from the separate schemas (which can be done in SQL simply by specifying the schema of each table say, first_schema.some_table JOIN second_schema.another_table)
I found that this is handled easily in Slick as long as the class for the tables in question include the schema name (I added it in manually and everything worked great). The problem is, slick's codegen isn't including the schema with it. I'm not sure how to fix this. I've been crawling through the source code and I'm not making much progress on the matter :(
It may be a bug in the schema reverse engineering.
Check out this guide to customizing the code generator.
http://slick.typesafe.com/doc/2.1.0/code-generation.html
Best would be if you determine why it happens and submit a fix to Slick if needed. This may require changed to the MySQLDriver#ModelBuilder.
To fix it just for you, you should modify the Model before giving it to the code generator. Alternatively you can override def Table#code .

Can MySql load from XML directly

I am aware of the batch LOAD XML technique e.g. Load XML Update Table--MySQL
Can MySql insert/replace rows directly from xml. I'd like to pass an XML string to MySQL.
Something like replace into user XML VALUES maybe even using as to map the tags to the column names??
The primary thing is that I dont want to parse the XML in my code, I'd like MySql to handle this. I dont have a file, I have the XML as a string.
I have looked and found there are some XML Functions:
12.11. XML Functions
The XML functions can do XPath, but I think this is a little fiddly as I have a 1:1 mapping from the XML to the table structure so I'd hjst like to be able to say hey MySql, insert the values in the xml string in to the table.
Is this possible?
In a nutshell, No.
What your looking for is an XML storage engine for MySQL. There has never been one created officially, and i have never seen a third party one either (but feel free to google).
If you really want to achieve this, then the closest you would get is to look for an alternative (R)DMS, but then that might not support the type of queries you wish to perform, may require a bit of a learning curve, would no doubt require you are using a server with superuser access, and potentially mean re-factoring a lot of your code.

Is there a Magento debug tool that lets me see database queries displayed in a similar manner to template path hints?

I have some corrupted data, an individual entry, in the database for my Magento installation. Since I can see the corrupted data displaying, I'd like to use a Magento extension to show me the database call displaying that data onscreen. Does such a tool exist? If not, what would be the best tool for SQL to gather this information?
You can see the SQL statement used to load a collection by using $collection->getSelect(). You'd have to narrow down the collection call first though, which might not be much help in your case.
http://blogs.ifuelinteractive.com/2009/10/18/logging-all-sql-in-magento/

xml to mysql database

I have a question. Does anyone have a working php script which can parse a XML file to a sql database? I have searched for some scripts and didn't find anything what looks like I can edit it to my needs.
Any help would be great!
Parse the XML using simplexml and extract the data of your interest from the XML file and insert into MySql using functions listed here.
Give it a try. Its not that difficult and you'll learn a lot.
It is not a PHP solution, but you can extract values from XML directly into mySQL:
http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html
Of course, if this is something you will need to do often, you can always fall back to what bzabhi have said.
Why not write one from scratch? Not that hard.