GithubHelp home page GithubHelp logo

teebes / squeak Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 2.0 98 KB

Python helper for SQLite3. Allows to drop, rename & alter columns.

Home Page: http://teebes.com/squeak/

License: MIT License

Python 100.00%

squeak's Introduction

Squeak

Python helper for sqlite3. Allows to drop & alter columns.

Installation

Squeak is contained in a single python file. Just download http://teebes.com/squeak.py into the directory of your choice and either run the file as a python executable or add it to your Python path.

If you'd like to get the git archive and build from source you can do:

$ git clone git://github.com/teebes/squeak.git
$ cd squeak
$ python setup.py install

Or, if you have pip, you can install with:

$ pip install git://github.com/teebes/squeak.git#egg=squeak

Usage

Sample usage for a sqlite3 database 'db' with the following table:

CREATE TABLE "my_table" (
"id" integer NOT NULL PRIMARY KEY, "name" varchar (20) NOT NULL DEFAULT ""

);

Examples from the command line

To drop the 'name' column:

$ squeak.py db my_table drop_column name

To rename the 'name' column to 'first_name':

$ squeak.py db my_table rename_column name first_name

To allow the 'name' column to be null:

$ squeak.py db my_table replace_definition name varchar \(20\)

Same examples from the python shell

To drop the 'name' column:

>>> from squeak import Squeak
>>> s = Squeak('db', 'my_table')
>>> s.drop_column('name')

To rename the 'name' column to 'first_name':

>>> from squeak import Squeak
>>> s = Squeak('db', 'my_table')
>>> s.drop_column('name')

To allow the 'name' column to be null:

>>> from squeak import Squeak
>>> s = Squeak('db', 'my_table')
>>> s.replace_definition('name', 'varchar (20)')

Tests

Squeak comes with a few unit tests. Just execute tests.py to run the suite.

squeak's People

Contributors

teebes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

goldenboy skifcha

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.