monitoring/ffmap/db/hoods.py

34 lines
799 B
Python
Raw Normal View History

#!/usr/bin/python3
2015-09-03 00:13:52 +02:00
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__) + '/' + '../..'))
2015-09-03 00:13:52 +02:00
from ffmap.mysqltools import FreifunkMySQL
2015-09-03 00:13:52 +02:00
mysql = FreifunkMySQL()
2015-09-08 21:23:22 +02:00
mysql.execute("""
CREATE TABLE hoods (
`id` int(11) NOT NULL,
`name` varchar(30) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`net` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
`lat` double DEFAULT NULL,
`lng` double DEFAULT NULL,
`cos_lat` double DEFAULT NULL,
`sin_lat` double DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
""")
mysql.execute("""
ALTER TABLE hoods
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name` (`name`),
ADD KEY `lat` (`lat`),
ADD KEY `lng` (`lng`),
ADD KEY `cos_lat` (`cos_lat`),
ADD KEY `sin_lat` (`sin_lat`)
""")
mysql.close()