I'm using Django + internal database(mysql).
but, I need to query to another external database(mysql).
In case, Can I make to model of external database?
The database is already exist. Only need to query..
Thank you.
I think you'll need to take a look at this documentation. It explain how to register multi databases and then query from them. https://docs.djangoproject.com/en/dev/topics/db/multi-db/
To be specific from which DB you query you can jump to this part of the docs https://docs.djangoproject.com/en/dev/topics/db/multi-db/#manually-selecting-a-database-for-a-queryset
Related
I used OrmLite to map Java objects in my Google App Engine application to a bunch of database tables (MySQL). Is there a way to automatically create the tables on Google's Cloud SQL or a similar cloud based SQL service instead of having to manually create the tables myself.
OrmLite's documentation does not cover this, neither does Google App Engine's.
Any pointer in the right direction is highly appreciated.
Is there a way to automatically create the tables ...
OrmLite's documentation does not cover this ...
I'm not sure if you are talking specifically about cloud SQL but ORMLite certainly has a ton of documentation about creating tables in general.
TableUtils is the class that supports (uh) table utility methods like create and delete. Here's the javadocs.
In the Getting Started section it talks about using TableUtil to create the schema in the Code Example. More details in the How To Use
In the documentation index I see entries for: "creating a table" and "table creation".
To quote from the sample code from the Getting Started docs.
// instantiate the dao
Dao<Account, String> accountDao =
DaoManager.createDao(connectionSource, Account.class);
// if you need to create the 'accounts' table make this call
TableUtils.createTable(connectionSource, Account.class);
TableUtil also has a method that returns the SQL statements that do the create.
Apologies if this question has been asked before.
I am new to Mule and I need a bit of help on how to export a certain row from a Table as an XML. Is it a good idea to use the poll scope to handle this?
I need the XML to plug it in an external program. Any ideas or simple examples I can play with?
thanks and Have a good day
You can use Poll scope with Database connector in it to select the records you want to transform. Then yo can use DataWeave to transform that to xml or Object to XML transformer to convert to XML as-is.
Using Poll or HTTP Request depends on your requirement, if you need to get the records based on a particular schedule then you can Use Poll(where this jus acts as a schedule for the database call). If you want this to happen with any external trigger then go for HTTP.
Then use the Database transformer/message Processor from the pallette, configure your Database and in the configuration you can write the select query with what ever the fields required.
then you can play the with the structure returned with value to map with the xml transformer object.
Hope this helps you, people have given the same answer but i thought this should be add on to those and helps.
Use a Database Component to poll out records from database.
In my knowledge there is no connector to transform database to xml as you need.
Use a custom transformer to convert database resultset to xml.
Go through This link
Db to XMl tranformation in Mule
Once you got the required xml the its your scope to decide where to you to push that output.
Kindly share the xml config to help further.
Cheers!
*This is not really a programming question. On wordpress front-end I have a custom made form. I want to store the form entries in a database table on wordpress back-end. Is there any way(plugin) to do this.
In order to insert data into a database table, it is a best practice to use $wpdb. The WordPress Codex can provide you with examples and more information to help you proceed.
It's exactly the same as a normal MySQL query using PHP only you're using the wpdb class for some PHP variables. Just output your query string which uses wpdb. If it looks like a normal MySQL query that would work, then it will work with the wpdb.
I was looking for linq to entities extension which allows to add OPTION(MAXDOP x) to the query generated. For queries I want to limit their SQL Server resources.
Something like:
Customers.WithMaxDop(2).Where(...) ..
Couldn't find.
Before I try to dig-in to create my own extension I wanted to ask you guys first for help - how would you suggest to do so?
Thanks!
That is query hint which cannot be added by extension method. You must either build whole new EF provider or wrap the query with the hint into database view and map the view as the new read only entity.
EF is abstraction on top of database (theoretically any database) - it is not supposed to offer you control over such DB details. If you want these details you must code them on database layer and only expose views or stored procedures to EF.
It seems that it is now possible with EF Core 3.x.
You can "Intercept Database operetation" at a low level, before and/or after the operation. In the example provided by Microsoft, they added an hint at the end of the query.
command.CommandText += " OPTION (OPTIMIZE FOR UNKNOWN)";
However, I don't know if this will occur for each and any operation, or if you can apply those interceptions only on selected commands.
More info here: https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.x/#interception-of-database-operations
I am building a site that needs to display some product info from a Magento Database, but display it on another page/site outside the Magento intallation. I know the information gets displayed twice, but I would like the site to avoid content duplication and pull that same info from an only source, the Magento product database.
Is this posible? Has anyone done it?
What would be a lot easier to do would be to pull in the entire Magento engine into your external page. This [unlike the rest of Magento] is pretty easy to do.
All you have to do is the following:
// Load Up Magento Core
define('MAGENTO', realpath('/var/www/magento/'));
require_once(MAGENTO . '/app/Mage.php');
$app = Mage::app();
Now you can use any of the Magento objects/classes as if you were inside of Magento and get your attributes
$product = Mage::getModel('catalog/product')->load(1234);
$product->getSku();
$product->getYourCustomAttribute();
etc etc.
Yes, I've done it a few ways. The safest way to do this is using the webservices Magento exposes to query objects programmatically. This will insulate you from database-level changes (such as the flat product catalog, a recent addition).
Failing that (if the performance of the webservices doesn't meet your needs), you can reconstruct the catalog data from the database directly. Use the following tables (assuming you're not using the flat catalog):
eav_entity_type
eav_attribute
catalog_product_entity
catalog_product_entity_int
catalog_product_entity_varchar
catalog_product_entity_text
catalog_product_entity_decimal
catalog_product_entity_datetime
You'll want to read up on EAV models before you attempt this. Bear in mind that this is largely the topic over which people call Magento complicated.
Hope that helps!
Thanks,
Joe