0

I was wondering if there is a way to retrieve the MySQL code for DB setup. Right now it's using sqlite for output when I run 'manage.py sql management'

See below:

MB-PR0:users jg$ python manage.py sql management
BEGIN;
CREATE TABLE "management_service" (
    "id" integer NOT NULL PRIMARY KEY,
    "service_name" varchar(32) NOT NULL
)
;
CREATE TABLE "management_employee_services" (
    "id" integer NOT NULL PRIMARY KEY,
    "employee_id" integer NOT NULL,
    "service_id" integer NOT NULL REFERENCES "management_service" ("id"),
    UNIQUE ("employee_id", "service_id")
)
;
CREATE TABLE "management_employee" (
    "id" integer NOT NULL PRIMARY KEY,
    "first_name" varchar(32) NOT NULL,
    "last_name" varchar(32) NOT NULL,
    "email" varchar(32) NOT NULL,
    "gmail_active" bool NOT NULL,
    "employee_status" bool NOT NULL
)
;
CREATE TABLE "management_note" (
    "id" integer NOT NULL PRIMARY KEY,
    "note_name" text NOT NULL,
    "employee_id" integer NOT NULL REFERENCES "management_employee" ("id")
)
;
COMMIT;

Is there a way to have this output as MySQL?

Thanks!

2 Answers 2

1
  1. Change your settings.py file to use MySQL
  2. run manage.py sql management
  3. Change your Settings.py file back.

I think that should work. I've never tried it though.

Sign up to request clarification or add additional context in comments.

Comments

0

This looks like basic SQL syntax. Can't you use this script by just running it via commandline?

$ mysql <my_db_name> -u<user_name> -p < mysql.sql

(This is using commandline redirecting) You will be asked for your password after pressing enter, then the script is executed.

Before that you can check if it is installed:

$ mysql -V

..or do you have phpmyadmin or the MySQL "IDE" installed? At least from the last one you could execute the script from a GUI desktop application, if needed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.