简体   繁体   中英

Partitioned MySQL table in Django

Is it possible to create a partitioned MySQL table in Django? Any example in that front will be really helpful.

I did as like the below by using sql hook of django:

  1. Get SQL statement generated by django with 'python manager.py sql '
  2. Copy create and alter table SQL statements of table your need to modify
  3. mkdir 'sql' under your application
  4. create .sql file in sql folder
  5. Add SQL statement as like the below

yourmodelname.sql file:

DROP TABLE <table name>;

CREATE TABLE `<table name>` (
      `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
      `testcase_id` integer NOT NULL,
      `databytes` integer NOT NULL,
      `direction` integer NOT NULL,
      `seconds` integer NOT NULL
) PARTITION BY LINEAR KEY (id) PARTITIONS 4;

COMMIT;

You don't need to involve Django at all. Just do table partitioning in plain mysql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM