Browse Source

Official sqlite db support

The best database ever.
tags/1.1
dequis 7 years ago
parent
commit
f5911a78b1
3 changed files with 25 additions and 6 deletions
  1. +8
    -1
      config.py.example
  2. +4
    -0
      config_defaults.py
  3. +13
    -5
      model.py

+ 8
- 1
config.py.example View File

@@ -2,7 +2,14 @@
# Wakarimasen configuration
ADMIN_PASS = 'desu' # Admin password. For fucks's sake, change this.
SECRET = 'desu' # Cryptographic secret. CHANGE THIS to something totally random, and long.
SQL_ENGINE = 'mysql://desu:desu@localhost/desu'

# engine configuration for mysql
SQL_ENGINE = 'mysql:///username:password@localhost/database'

# engine configuration for sqlite (requires disabling pooling)
#SQL_ENGINE = 'sqlite:///wakarimasen.sqlite'
#SQL_POOLING = False

#SQL_BACKUP_TABLE = '__waka_backup' # Table backup
#SQL_ADMIN_TABLE = 'admin' # Table used for admin information
#SQL_PROXY_TABLE = 'proxy' # Table used for proxy information


+ 4
- 0
config_defaults.py View File

@@ -1,4 +1,8 @@

SQL_POOLING = True
SQL_POOL_SIZE = 100
SQL_POOL_MAX_OVERFLOW = 10

SQL_ADMIN_TABLE = 'admin'
SQL_PROXY_TABLE = 'proxy'
SQL_REPORT_TABLE = 'reports'


+ 13
- 5
model.py View File

@@ -1,12 +1,20 @@
import config, config_defaults
from sqlalchemy import create_engine
from sqlalchemy import Table, Column, Integer, Text, String, MetaData, Boolean
from sqlalchemy.orm import sessionmaker, mapper, scoped_session
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.sql import func
from sqlalchemy import Table, Column, Integer, Text, String, MetaData
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.exc import OperationalError
from sqlalchemy.sql import func

pool_opts = {}

if config.SQL_POOLING:
pool_opts = {
'pool_size': config.SQL_POOL_SIZE,
'max_overflow': config.SQL_POOL_MAX_OVERFLOW,
}

engine = create_engine(config.SQL_ENGINE, **pool_opts)

engine = create_engine(config.SQL_ENGINE, pool_size=100, max_overflow=10)
Session = scoped_session(sessionmaker(bind=engine))
metadata = MetaData()



Loading…
Cancel
Save