Browse Source

Database schema, hashing module, some other things.

tags/v1.0^2
Ben Kurtovic 10 years ago
parent
commit
085fd62704
4 changed files with 32 additions and 7 deletions
  1. +1
    -0
      .gitignore
  2. +5
    -5
      bitshift/database.py
  3. +23
    -0
      schema.sql
  4. +3
    -2
      setup.py

+ 1
- 0
.gitignore View File

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


# github premade rules # github premade rules
*.py[cod] *.py[cod]


+ 5
- 5
bitshift/database.py View File

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


import mmh3
import oursql import oursql


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


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


def _connect(self): def _connect(self):
pass

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


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

+ 23
- 0
schema.sql View File

@@ -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 View File

@@ -4,8 +4,9 @@ setup(
name = "bitshift", name = "bitshift",
version = "0.1", version = "0.1",
packages = find_packages(), 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", author = "Benjamin Attal, Ben Kurtovic, Severyn Kozak",
license = "MIT", license = "MIT",
url = "https://github.com/earwig/bitshift" url = "https://github.com/earwig/bitshift"


Loading…
Cancel
Save