Exemplo n.º 1
0
Arquivo: __init__.py Projeto: dax/jcl
def db_connect():
    """
    Create a new connection to the DataBase (SQLObject use connection
    pool) associated to the current thread.
    """
    #if not jcl.model.db_connected:
    jcl.model.hub.threadConnection = connectionForURI(db_connection_str)
Exemplo n.º 2
0
 def __init__(self):
     connection = connectionForURI("sqlite:/:memory:")
     sqlhub.processConnection = connection
     try:
         User.createTable()
         Stocks.createTable()
     except:
         pass
Exemplo n.º 3
0
import os

from sqlobject.col import StringCol, ForeignKey, BoolCol
from sqlobject.dbconnection import connectionForURI
from sqlobject.main import sqlhub, SQLObject

db_filename = os.path.abspath('data.db')
connection_string = 'sqlite:' + db_filename
connection = connectionForURI(connection_string)
sqlhub.processConnection = connection


class User(SQLObject):
    username = StringCol(unique=True, notNone=True)
    country_code = StringCol(notNone=True)

    @staticmethod
    def get_user(username):
        return User.selectBy(username=username.lower()).getOne(default=None)


class Stream(SQLObject):
    user = ForeignKey('User')
    title = StringCol(notNone=True)
    url = StringCol(notNone=True)
    ended = BoolCol(default=False)

User.createTable(ifNotExists=True)
Stream.createTable(ifNotExists=True)
Exemplo n.º 4
0
Arquivo: DBCo.py Projeto: philn/alinea
def main():
    if len(sys.argv[1:]) != 2:
        usage()
    oldConn = dbconnection.connectionForURI(sys.argv[1])
    newConn = dbconnection.connectionForURI(sys.argv[2])
    dbCopy(oldConn, newConn)