GithubHelp home page GithubHelp logo

ksava / fsqlf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dnsmkl/fsqlf

1.0 2.0 1.0 251 KB

Free SQL Formatter

Home Page: http://fsqlf.sourceforge.net/

License: GNU Lesser General Public License v3.0

fsqlf's Introduction

Free SQL Formatter

Licensed under LGPL.
Full license is available in file `LICENCE' which you should have received with the program



Table of content:
-----------------------------------
1. Current state of development
2. Compilation
2.1 Requirements
2.2 Compilation process
3. TODO lists
4. Usage
4.1 Usage commandline
4.2 Usage graphical user interface
5. Project site

APPENDIX.1 - wxWidgets installation
-----------------------------------



1. Current state of development
    My use case is formating generated SQL code - make something readable out of one long line of SQL code

    Current list of implemented capabilities:
    - indent subqueries
    - new line in cases where it seems appropriate (items in SELECT list. Keywords FROM, JOIN, ON, WHERE, AND, OR )
    - capitalisation of recognised keywords (not all - I like some keywrods lowercase, but this should be configurable eventualy)
    - gui
    - configurations read from file

    (see TODO list what is planed for future)



2. Compilation
2.1 Requirements
    The following list actualy should be suficient. Look into `makefile' for compilation instructions
    - flex         # http://flex.sourceforge.net/
    - C compiler   #
    - wxWidgets    # needed for Graphical User Interface (GUI)
    - C++ compiler # for compiling GUI

    Stuff that I got installed:
    - flex      # http://flex.sourceforge.net/
    - gcc
    - wxWidgets # needed for Graphical User Interface (GUI). If you want to build Windows executables on Linux machine see ``APPENDIX.1 - wxWidgets installation''
    - g++       # for compiling GUI
    - make      # This makes all compiling automated
    - mingw32   # cross compiler which is used to produce Windows executables under Linux
    - zip       # used only for creating zip archive with source code and executable files
    - git       # used for version control and craeting zip archive with source code and executable files



2.2 Compilation process
    General instructions
    - Use `flex' on core/fsqlf.lex
    - Compile its output with C compiler and name the executable `fsqlf.exe' if you on Windows and `fsqlf' in other cases
    - Compile `gui/gui_wx_basic.cpp' with C++ compiler
    - Put both executables `fsqlf' and `gui_wx_basic' into one directory.

    If you use Linux and have installed same programs as I do (see section 2.1), then you can use the make file
    > make all      # Compile source for LINUX and WINDOWS. Excutables can be found in `bin/' directory:  `fsqlf', `fsqlf.exe', `gui_wx_basic', `gui_wx_basic.exe'
    > make test     # Compile and run program on test file `test.sql' and print output to console
    > make zip      # Create zip archive with executables and source code binaries (for publishing)
    > make clean    # Remove all files created with other make commands



3. TODO lists:
    basic - to have working version 1
    - `in' statements [done]
    - comments one line [done]
    - comments multiline [done]
    - strings [done]
    - subqueries in FROM/JOIN parts [done]
    - OR [done]
    - paranthesis in restrictions (e.g.   AND (a=1 OR b=1)   )
    - paranthesis in FROM/JOIN parts (e.g.   FROM X LEFT JOIN (Y JOIN Z)   ) [sort of done: program does not crash if it encounters this, but I can not think of any good way to actualy format it]

    extention #1 - more comfortable usage (next level)
    - formating configurations [done: default formatting can be overriden in file `formatting.conf']
    - reading command line arguments [in progress: now only input/output arguments]
    - GUI [in progress: need to polish some stuff, but usable, has drag'n'drop functionality]

    extension #2 - better formating
    - `case' statements (redo stack functions; add handling)
    - analytical functions

    possible extra functionality/ideas for the future
    - in equality condition align all comparison signs ('=' , '<>', etc.)
    - align comments them selfs and content of comments



4.1 Usage commandline
    Windows
        bin/fsqlf.exe                         # read from stdin, write to stdout
        bin/fsqlf.exe input_file              # read from file, write to stdout
        bin/fsqlf.exe input_file output_file  # use files for reading and writing
    Usage in Linux is equivalent, just without the extention `.exe'
    Forrmating configurations can be changed in `formatting.conf'



4.2 Usage graphical user interface
    Go to directory `bin/' (this is needed so `gui_wx_basic.exe' would be in the same folder as `fsqlf.exe')
    In Windows execute `gui_wx_basic.exe'
    In Linux execute `gui_wx_basic'

    When it starts, just fill your code into the formater window and press `Format'
    Forrmating configurations can be changed in `formatting.conf'



5. Project site
    Most recent source code can be found at sourceforge.
    Project site address http://sourceforge.net/projects/fsqlf/
    Source can also be forked at github https://github.com/dnsmkl/fsqlf












##################################################
##################################################
##################################################
APPENDIX.1 - wxWidgets installation

I use debian, so I describe what I did. Your system probably is different, but maybe this will at least give you an idea in which direction to go.


##
## System preparation
##
Install WxWidgets needs to be installed
(http://wiki.wxwidgets.org/Installing_and_configuring_under_Ubuntu)

  # apt-get install wx2.8-headers libwxgtk2.8-0 libwxgtk2.8-dev
  # cd /usr/include
  # ls | grep wx
  # ln -sv wx-2.8/wx wx


##
## System preparation for compiling windows binaries
##
Install mingw (cross) compiler
  # apt-get install mingw32

Download wxWidgets source from http://www.wxwidgets.org/
(some forums mention that sources provided by ubuntu/debian are not good)

Build wxWidgets with mingw
  # ./configure --prefix=/usr/i586-mingw32msvc --host=i586-mingw32msvc --build=`./config.guess` --enable-unicode --disable-shared
  # make
  # make install
  # cd /usr/i586-mingw32msvc/include
  # ln -sv wx-2.8/wx wx



##
## References
##
This was done by following instructions found in   http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux
with little adjustment by after reading   http://forums.codeblocks.org/index.php?topic=7988.msg%msg_id%
and   http://old.nabble.com/mingwm10.dll-ts8920679.html

fsqlf's People

Contributors

dnsmkl avatar xevix avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.