Django using external mysql DB - best way to tackle - mysql

I have scanned all of the similar titles and questions regarding my issue and also the django website itself and I cannot find the best solution. I apologize if this has been answered.
My django is configured to use a MySQL database with information already inside of it.
I have a database with tables created inside of them in which I will only need to read from to build graphs.
Should I build a model for each one of these types of tables?
Basically a new table named simulation_log201403 is created each time we run a simulation. Inside of this we have a timestamp, node, ppsavg etc. This simulation ID is linked to a computer_id.
Do I have to hand create each model based off my old database?
Thanks for the help

I'm not sure I understand your question. If you're asking how to use Django with a database not created by your Django models, read the chapter entitled Integrating Django with a legacy database.

Related

Do I need to create DB migration, if I have a designed DB in MySQL?

I designed a database in MYSQL. Now I want to connect that with my Laravel application. But after researching, I understand that I need to migrate the database into Laravel by creating migration tables. But doing the same thing that I did in MySQL is tedious. I think there is another way to do the stuff. After searching I got this article from stackoverflow, but this is related to yii framework. I think someone knows here the solution of my problem.
I don't see a problem here, you can just connect Laravel to your DB (by editing your .env file) without any problems, migration files are just an easier way to design and implement your tables (also altering your tables' scheme on production is a very useful usage for migrations), but with that being done then no further actions are required, and you are good to go!
it's pretty obvious, you can update the database setting in the .env file and use DB::table('your_table_name') and get whatever query you want.
The upside of using migrations is that the exact same database can be created on different systems (ex: co-workers or acceptance/production servers).
Laravel migrations have an up and a down function so you can rollback to a specific version if something went wrong, very usefull when publishing your code.
That being said, co-workers could also review the database changes and for example hint at using more indexes and foreign keys.
As the other comments said, it's not a requirement you use migrations but it has considerable advantages versus creating and updating the database manually.

Manually input orders in woocommerce databases?

I have a question about manually inputting information in a MySQL databases (specifically in meaning Woocommerce order databases). I have some orders, that I get from another database and have to input them in in a Woocommerce database, which by now I found out that it consists out of several different ones, and not from just one. The Woocommerce is a plugin in Wordpress. Does anybody have any idea on how that could be done?
Some additional information: I am working with Wordpress 4.4.2 and Woocommerce 2.5.5.
I would not try to directly insert data into woocommerce's database because this method is not really documented and would require intricate knowledge of woocommerce's database.
I would rather use woocommerce's rest api to create the orders. The documentation has examples for various programming languages. There is another bulk creation api as well, but found no examples on how exactly to use that one, since the example in the documentation is on bulk updates only.

Is it possible to write mysql queries in Angular.JS?

Im new to Angular.JS and just wondering if it is possible to write mysql queries in angularjs?
I would like this as I am trying to create a messaging system in which I query the database and get the information live to the webpage.
Any help is appreciated, hope the question is reasonable. Gab
That is not advisable (if possible at all) as it would defeat the purpose of Angular.
You should consume data by targeting a RESTful api/service exposed by the server. The service would handle the DB access for you and provide the data to Angular using a more portable format (e.g. JSON or XML)
Some of the basics of linking Angular and REST are described here
There are related questions on SO about exposing your particular DB flavor using REST here.
This can only be a starting point but it should give you some ideas. I will try to amend this with more info as I come across it.

Creating a CakePHP REST api from an existing project

I have a webapp which I am planning on converting into a REST api and have decided to use CakePHP for this - the current form is written in ColdFusion.
The database is a couple million records in size with 20 tables or so and a few associative tables that handle the many-to-many situations.
I'm looking for the best method to start the CakePHP solution mainly in regards to the database. Should I import my existing db and just use cake to access its current form? Should I bake a fresh database structure (in order to stay within the cake standards) then figure out how to get my data into the new db, and maintain relationships etc (how?)?
Edit:
There are many users on the existing app, but when the new CakePHP api is setup and ready to go, the old service will be closed to use the new one.
The current app is not designed in an MVC way, are you referring to Models as being synonymous with Tables? There are many existing tables with foreign key relationships but they are not named using the CakePHP standards - so not sure if this will break CakePHP or make its features not as usable.
Time is an issue, but I'd rather take the time now and get it done the correct way, instead of having to re-visit shortly.
I largely depends on your situation:
Are there people using the old application? - This will mean you
can't really create another database for your new app if you want to
access new information.
Is there really a need to change the relationships of models? - I don't think you should change unless you
really need to.
Cost - How much time are you willing to spend on the migration?
Note:
You can modify almost everything on your model to cope up with the previous database/table structure.

Django: Select data from already existed tables

I am new to the world of Django. I am developing an application which will manipulate data on some new tables and some others that are already existed. Until now I knew how to create a new model and when I issue the ..syncdb command a corresponding, to the model, table will be created.
The other tables are used from another (not mine) application. How do you believe is the best way to proceed?
Thank you!
The documentation has a whole page on dealing with legacy databases, including how to autogenerate your models from the existing database.