瀏覽代碼

Database schema, hashing module, some other things.

tags/v1.0^2
Ben Kurtovic 10 年之前
父節點
當前提交
085fd62704
共有 4 個檔案被更改,包括 32 行新增7 行删除
  1. +1
    -0
      .gitignore
  2. +5
    -5
      bitshift/database.py
  3. +23
    -0
      schema.sql
  4. +3
    -2
      setup.py

+ 1
- 0
.gitignore 查看文件

@@ -1,5 +1,6 @@
.sass-cache
.DS_Store
.my.cnf

# github premade rules
*.py[cod]


+ 5
- 5
bitshift/database.py 查看文件

@@ -3,19 +3,18 @@ Module with classes and functions to handle communication with the MySQL
database backend, which manages the search index.
"""

import mmh3
import oursql

class Database(object):
"""Represents the MySQL database."""

def __init__(self):
pass
self._connect()

def _connect(self):
pass

def _create(self):
pass
"""Establish a connection to the database."""
self._conn = oursql.connect()

def search(self, query):
"""
@@ -36,4 +35,5 @@ class Database(object):
:param codelet: The codelet to insert.
:type codelet: :py:class:`.Codelet`
"""
# code_hash = mmh3.hash64(codelet.code)[0]
pass

+ 23
- 0
schema.sql 查看文件

@@ -0,0 +1,23 @@
CREATE DATABASE bitshift DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `bitshift`;

CREATE TABLE codelets (
`codelet_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
`codelet_name` VARCHAR(512) NOT NULL,
`codelet_code_id` BIGINT UNSIGNED NOT NULL,
`codelet_lang` SMALLINT UNSIGNED DEFAULT NULL,
`codelet_origin` TINYINT UNSIGNED DEFAULT NULL,
`codelet_url` VARCHAR(512) NOT NULL,
`codelet_date_created` DATETIME DEFAULT NULL,
`codelet_date_modified` DATETIME DEFAULT NULL,
PRIMARY KEY (`codelet_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE code (
`code_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
`code_hash` BIGINT NOT NULL,
`code_code` MEDIUMTEXT NOT NULL,
PRIMARY KEY (`code_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- separate tables: authors, symbols, caches, search indices

+ 3
- 2
setup.py 查看文件

@@ -4,8 +4,9 @@ setup(
name = "bitshift",
version = "0.1",
packages = find_packages(),
install_requires = ["Flask>=0.10.1", "pygments>=1.6", "requests>=2.2.0",
"BeautifulSoup>=3.2.1", "oursql>=0.9.3.1"],
install_requires = [
"Flask>=0.10.1", "pygments>=1.6", "requests>=2.2.0",
"BeautifulSoup>=3.2.1", "oursql>=0.9.3.1", "mmh3>=2.3"],
author = "Benjamin Attal, Ben Kurtovic, Severyn Kozak",
license = "MIT",
url = "https://github.com/earwig/bitshift"


Loading…
取消
儲存