Skip to content

traP-jp/h24w-17

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

(名称未定)

How to use

Extractor

Static Extractor

TODO

Dynamic Extractor

  1. add import statement
import (
  dynamic_extractor "github.com/traP-jp/h24w-17/extractor/dynamic"
)
  1. add the code to start server
func main() {
  dynamic_extractor.StartServer()
  // ...
}
  1. replace driver mysql with mysql+analyzer
  2. running your application
  3. access http://localhost:39393 and get the query list

Getting Table Schemas

DATABASE='isupipe'
mysql -u root -ppass -h 127.0.0.1 -N -e "SHOW TABLES FROM $DATABASE" | while read table; do mysql -u root -ppass -h 127.0.0.1 -e "SHOW CREATE TABLE $DATABASE.\`$table\`" | awk 'NR>1 {$1=""; print substr($0,2) ";"}' | sed 's/\\n/\n/g'; done > schema.sql

Cache Plan

Format

type Format = {
  queries: Query[]
}

type Query = SelectQuery | UpdateQuery | DeleteQuery | InsertQuery

type Placeholder = {
  index: number;
  extra?: boolean
}

type Condition = {
  column: string
  operator: 'eq' | 'in'
  placeholder: Placeholder
}

type SelectQuery = CachableSelectQuery | NonCachableSelectQuery

type CachableSelectQuery = {
  type: 'select'
  query: string
  cache: true
  table: string
  targets: string[]
  conditions: Condition[]
  orders: {
    column: string
    order: 'asc' | 'desc'
  }[]
}

type NonCachableSelectQuery = {
  type: 'select'
  query: string
  cache: false
}

type UpdateQuery = {
  type: 'update'
  query: string
  table: string
  targets: string[]
  conditions: Condition[]
}

type DeleteQuery = {
  type: 'delete'
  query: string
  table: string
  conditions: Condition[]
}

type InsertQuery = {
  type: 'insert'
  query: string
  table: string
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages