GithubHelp home page GithubHelp logo

github30 / kizoona.js Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 40 KB

HTTP MySQL/SQLite Proxy

Home Page: https://codepen.io/04/full/poBYQxN

License: MIT License

Dockerfile 4.67% PHP 19.10% JavaScript 76.22%
database devcontainer github http http-proxy https https-proxy javascript mysql pdo pdo-mysql pdo-sqlite php sql sqlite test

kizoona.js's Introduction

Warning

Do not use in production environment

KiZooNa.js

HTTP MySQL/SQLite Proxy

<html>

<body>
  <script src="https://github30.github.io/KiZooNa.js/KiZooNa.js"></script>
  <script type=module>
    const db = new DB({
      url: 'http://localhost/sql-injection.php',
      dsn: 'mysql:host=127.0.0.1;dbname=mariadb',
      username: 'mariadb',
      password: 'mariadb'
    })
    
    await db.createTable('users', table => {
      table.increments('id')
      table.string('name', 255).nullable().default(null)
      table.integer('age').nullable().default(null)
      table.timestamp('created_at').useCurrent()
    })
    
    await db.table('users').insert({ name: 'Jake', age: 29 })
    console.table(await db.table('users').get())

    await db.table('users').where('name', 'Jake').update({ age: 31 })

    await db.table('users').where('name', 'Jake').delete()
  </script>
</body>

</html>

SQLite

<html>

<body>
  <script src="https://github30.github.io/KiZooNa.js/KiZooNa.js"></script>
  <script type=module>
    const db = new DB({
      url: 'http://localhost/sql-injection.php',
      dsn: 'sqlite:./foobar.db'
    })
    
    await db.createTable('users', table => {
      table.increments('id')
      table.string('name', 255).nullable().default(null)
      table.integer('age').nullable().default(null)
      table.timestamp('created_at').useCurrent()
    })
    
    await db.table('users').insert({ name: 'Jake', age: 29 })
    console.table(await db.table('users').get())

    await db.table('users').where('name', 'Jake').update({ age: 31 })

    await db.table('users').where('name', 'Jake').delete()
  </script>
</body>

</html>

TEST

node --run test

Usage

<html>

<body>
  <script src="https://github30.github.io/KiZooNa.js/KiZooNa.js"></script>
  <script type=module>
    const db = new DB({
      url: 'http://localhost/sql-injection.php',
      dsn: 'mysql:host=127.0.0.1;dbname=mariadb',
      username: 'mariadb',
      password: 'mariadb'
    })
    console.log(await db.query('SHOW DATABASES'))
    console.log(await db.query('SHOW TABLES'))
    
    await db.createTable('users', table => {
      table.increments('id')
      table.string('name', 255).nullable().default(null)
      table.integer('age').nullable().default(null)
      table.timestamp('created_at').useCurrent()
    })
    
    var lastInsertId = await db.table('users').insertGetId({ name: 'Jake', age: 29 })
    console.table(await db.table('users').get())

    // Multiple insert
    var affectedRows = await db.table('users').insert([
      { name: 'Alice', age: 29 },
      { name: 'Bond', age: db.raw('ROUND( RAND() * 50 + 100 )') },
      { name: 'Cargo', age: 31 }
    ])

    // ['Jake', 'Alice', 'Bond', 'Cargo']
    console.log(await db.table('users').pluck('name'))
    // { 1: 'Jake', 2: 'Alice', 3: 'Bond', 4: 'Cargo' }
    console.log(await db.table('users').pluck('name', 'id'))

    console.log(await db.table('users').count())
    console.log(await db.table('users').max('age'))
    console.log(await db.table('users').min('age'))
    console.log(await db.table('users').avg('age'))
    console.log(await db.table('users').sum('age'))

    console.table(await db.table('users').select('name').get())
    console.table(await db.table('users').limit(3).get())
    console.table(await db.table('users').where('name', 'Cargo').orderBy('age').get())
    console.table(await db.table('users').orderByDesc('name').offset(2).limit(3).get())
    console.table(await db.table('users').groupBy('name').get())

    console.log(await db.table('users').find(3))

    console.log(await db.table('users').first())
    console.log(await db.table('users').where('id', 2).value('age'))
    console.log(await db.table('users').oldest().get())
    console.log(await db.table('users').latest().get())

    var affectedRows = await db.table('users').where('name', 'Jake').update({ age: 31 })

    var affectedRows = await db.table('users').where('name', 'Jake').delete()
    await db.dropTable('users')
  </script>
</body>

</html>

kizoona.js's People

Contributors

github30 avatar

Stargazers

pianopia avatar

Watchers

 avatar

Forkers

pianopia

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.