MySQL 支援GeoDjango的簡單說明

2021-07-09 07:09:00 字數 1875 閱讀 7440

1.安裝

(1)安裝geos

database

library requirements

supported versions

notes

postgresql

geos, proj.4, postgis

9.1+

requires postgis.

mysql

geos

5.5+

not ogc-compliant.

oracle

geos

11.2+

xe not supported.

sqlite

geos, gdal, proj.4, spatialite

3.6.+

requires spatialite 2.4+, pysqlite2 2.5+

從上表可知:對於mysql,只需安裝geos;

對於postgresql,需要安裝proj.4、postgis

對於sqlite,需安裝proj.4、gdal、spatialite

install/geolibs/

db-api/#mysql-spatial-limitations

由於目前我們伺服器上使用的是mysql,所以按mysql進行配置:安裝geos

$ wget 

$ tar xjf geos-3.4.2.tar.bz2

然後解壓、編譯、安裝

$ cd geos-3.4.2

$ ./configure

$ make

$ sudo make install

$ cd ..

執行完上述幾步,想知道geos是否安裝正確,可用下面的命令:

進入python shell,鍵入下面的命令,如果不報錯,則認為安裝正確。

from 

django.contrib.gis.db

importmodels

(2)修改settings.py

django.contrib.gis',

b.修改資料庫引擎為'engine': 'django.contrib.gis.db.backends.mysql',

(3)在models.py中引入models

from django.contrib.gis.db import models

同時可以注釋掉from django.db import models

(4)測試:

在models.py(比如person表)中,新增以下字段:

point = models.pointfield(null=true,blank=true)

然後執行: 

./manage.py makemigrations

如果不報錯,則視為正確。

除了pointfield以外,還有多個空間型別,如下:

具體可參考geodjango models api的文件:

model-api/#spatial-field-types

php 支援 mysql php支援mysql配置

想在centos5.2上裝乙個discuz論壇,在突破了apache許可權問題後,發現discuz的提示資訊裡顯示不支援mysql mysql connect 不支援 請檢查mysql 模組是否正確載入 我自己寫個測試檔案 php view plaincopy phpinfo 執行後顯示 c sha...

mysql支援 mysql支援的資料型別

mysql支援的資料型別 一 整型 型別 tinyint 1位元組,取值範圍 128 127,預設長度4 smallint 2位元組,取值範圍 32768 32767,預設長度6 mediumint 3位元組 int 4位元組 2147483648 2147483647 bigint 8位元組 約束...

MySQL支援中文

1.修改資料庫編碼格式為utf8 推薦 create database db name default character set utf8 2.修改表的編碼格式為utf8 不推薦 在建立表後,插入資料之前,將表的編碼格式設定成utf8 alter table table name convert ...