示例#1
0
def get_pool():
    return PooledPostgresqlDatabase(DB_NAME,
                                    max_connections=DB_MAX_CONNECTIONS,
                                    user=DB_USER,
                                    password=DB_PASSWORD,
                                    host=DB_HOST,
                                    port=DB_PORT)
示例#2
0
def create_table():
    from peewee_async import PooledPostgresqlDatabase
    from app.models import database, tables

    app = create_app('testing')
    database.initialize(PooledPostgresqlDatabase(**app.config.DATABASE))
    database.drop_tables(tables, safe=True)
    database.create_tables(tables, safe=True)
示例#3
0
def get_pool(name, user, password, host, port, max_conn=2):
    """Get database pool"""
    return PooledPostgresqlDatabase(name,
                                    max_connections=max_conn,
                                    user=user,
                                    password=password,
                                    host=host,
                                    port=port)
示例#4
0
 def setUp(self):
     self.db = PooledPostgresqlDatabase(
         database=environ.get('PGDB', 'postgres'),
         user=environ.get('PGUSER', 'admin'),
         password=environ.get('PGPASS', 'admin'))
     self.db_manager = Manager(database=self.db)
     self.ar_strategy = PeweeActiveRecordStrategy(
         manager=self.db_manager,
         active_record_class=EventRecord
     )
     self.app = ToDoApplication(entity_active_record_strategy=self.ar_strategy, )
示例#5
0
 async def set_db(_app, _loop):
     database.initialize(PooledPostgresqlDatabase(**app.config.DATABASE))
     BaseModel.pee = Manager(database, loop=_loop)
     app.redis = await aioredis.create_pool(**app.config.REDIS)
示例#6
0
db_pass = '******'
server_ip = 'localhost'  # this will be used by the browser to callback here
listen_port = '80'
listen_ip = '0.0.0.0'  # IP to bind to for the server, 0.0.0.0 means all local IPv4 addresses
ssl_cert_path = './app/ssl/apfell-cert.pem'
ssl_key_path = './app/ssl/apfell-ssl.key'
whitelisted_ip_blocks = [
    '0.0.0.0/0'
]  # only allow connections from these IPs to the /login and /register pages
use_ssl = False
# --------------------------------------------
# --------------------------------------------
# --------------------------------------------
# custom loop to pass to db manager
dbloop = uvloop.new_event_loop()
apfell_db = PooledPostgresqlDatabase(db_name, user=db_user, password=db_pass)
apfell_db.connect_async(loop=dbloop)
db_objects = Manager(apfell_db, loop=dbloop)

apfell = Sanic(__name__, strict_slashes=False)
apfell.config[
    'WTF_CSRF_SECRET_KEY'] = 'really secure super secret key here, and change me!'
apfell.config['SERVER_IP_ADDRESS'] = server_ip
apfell.config['SERVER_PORT'] = listen_port
apfell.config['DB_USER'] = db_user
apfell.config['DB_PASS'] = db_pass
apfell.config['DB_NAME'] = db_name
apfell.config['DB_POOL_CONNECT_STRING'] = 'dbname=' + apfell.config[
    'DB_NAME'] + ' user='******'DB_USER'] + ' password='******'DB_PASS']
apfell.config['API_VERSION'] = "1.0"
示例#7
0
文件: __init__.py 项目: zforks/Apfell
listen_ip = '0.0.0.0'  # IP to bind to for the server, 0.0.0.0 means all local IPv4 addresses
ssl_cert_path = './app/ssl/apfell-cert.pem'
ssl_key_path = './app/ssl/apfell-ssl.key'
whitelisted_ip_blocks = [
    '0.0.0.0/0'
]  # only allow connections from these IPs to the /login and /register pages
use_ssl = False
server_header = "nginx 1.2"
# --------------------------------------------
# --------------------------------------------
# --------------------------------------------
# custom loop to pass to db manager
dbloop = uvloop.new_event_loop()
apfell_db = PooledPostgresqlDatabase(db_name,
                                     user=db_user,
                                     password=db_pass,
                                     host='127.0.0.1',
                                     max_connections=100)
apfell_db.connect_async(loop=dbloop)
db_objects = Manager(apfell_db, loop=dbloop)

apfell = Sanic(__name__, strict_slashes=False)
apfell.config[
    'WTF_CSRF_SECRET_KEY'] = 'really secure super secret key here, and change me!'
apfell.config['SERVER_IP_ADDRESS'] = server_ip
apfell.config['SERVER_PORT'] = listen_port
apfell.config['DB_USER'] = db_user
apfell.config['DB_PASS'] = db_pass
apfell.config['DB_NAME'] = db_name
apfell.config[
    'DB_POOL_CONNECT_STRING'] = "dbname='{}' user='******' password='******' host='127.0.0.1'".format(
示例#8
0
# Third-party imports
from peewee_async import PooledPostgresqlDatabase

DB_CONNECTION = PooledPostgresqlDatabase(database='awa_db',
                                         max_connections=1,
                                         user='******',
                                         password='******')
示例#9
0
from peewee_async import PooledPostgresqlDatabase

db = PooledPostgresqlDatabase(database='test',
                              user='******',
                              password='******',
                              host='localhost')

login_url = "/login"
PORT = 5000

if __name__ == "__main__":
    print(db.database)
示例#10
0
from peewee import (
    CharField,
    IntegerField,
    ForeignKeyField,
    Model,
)
from peewee_async import PooledPostgresqlDatabase

db = PooledPostgresqlDatabase('graphene_test',
                              user='******',
                              host='localhost')


class BaseModel(Model):
    class Meta:
        database = db


class Author(BaseModel):

    name = CharField()
    rating = IntegerField()


class Book(BaseModel):

    name = CharField()
    year = IntegerField()
    author = ForeignKeyField(Author)