예제 #1
0
from qaviton.utils.databases.sqlite import DataBase
from flask_examples.add_users_and_save_content_db_commands import DBCommands

database = DataBase('db.db', DBCommands)

def test_db():
    print(database.execute(database.command.get_user.format('bunbun')))
from qaviton.utils.databases.sqlite import DataBase
from flask_examples.add_users_and_save_content_db_commands import DBCommands

DBCommands.drop_users_table = 'DROP TABLE IF EXISTS users;'
DBCommands.create_users_table = '''
    CREATE TABLE IF NOT EXISTS users (
        id INTEGER PRIMARY KEY AUTOINCREMENT,
        username TEXT, 
        content TEXT
      );
'''

database = DataBase('db.db', DBCommands)

database.execute(database.command.drop_users_table)
database.execute(database.command.create_users_table)
def get_db():
    return DataBase('db.db', DBCommands)
예제 #4
0
        try:
            r = requests.get('https://web.whatsapp.com/')
            print(r.text)
        except:
            raise KeepAliveException(
                'you tried to handle an invalid url connection error but you failed'
            )


try:
    url_keep_alive()
except KeepAliveException:
    print(KeepAliveException)

from qaviton.utils.databases.sqlite import DataBase
db = DataBase('database')
r = db.execute('''CREATE TABLE contacts (
 contact_id integer PRIMARY KEY,
 first_name text NOT NULL,
 last_name text NOT NULL,
 email text NOT NULL UNIQUE,
 phone text NOT NULL UNIQUE
);''')
print(r)
try:
    db.close()
except:
    pass


def devide(a, b):
예제 #5
0
def create(db_path):
    with DataBase(db_path) as db:
        db.execute(create_users)
        db.execute(create_articles)
예제 #6
0
from qaviton.utils.databases.sqlite import DataBase

create_users = '''CREATE TABLE IF NOT EXISTS users (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                name text,
                email text,
                username text,
                password text);'''

create_articles = '''CREATE TABLE IF NOT EXISTS articles (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                title text,
                body text,
                author text,
                create_date text);'''

with DataBase('database.db') as db:
    db.execute(create_users)
    db.execute(create_articles)