Skip to content

Berchem/My_pseudo_SQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

My pseudo SQL

A python implementation of structure query language

Usage

MypseudoSQL.Table(columns)

from MypseudoSQL import Table

table = Table(["col_0", "col_1", ...])

table.insert([val_0, val_1, ...])

Parameters

columns: specifying the names of the table's columns

list

Attributes

rows: a dataset as a row which values corresponding to table's columns

list

Methods

MypseudoSQL SQL
insert(row_values) INSERT INTO
update(updates, predicate) UPDATE
delete() DELETE
select() SELECT
limit(lim) LIMIT
where() WHERE
group_by(group_by_columns, aggregates) GROUP BY
order_by(order) ORDER BY
join(other_table) JOIN

insert(row_values)

dict from column names to values

parameter:

row_values: dict of list

return:

void

update(updates, predicate)

updates will be a dict whose keys are the columns to update and whose values are the new values for those fields.

predicate is a predicate that returns True for rows that should be updated, False otherwise

parameter:

updates: dict

return:

void

delete(predicate=function)

to delete rows from a table

parameter:

predicate: a predicate function, default=lambda row: True

return:

void

select(keep_columns=None, additional_columns=None)

keep_columns specifies the name of the columns you want to keep in the result.

additional_columns is a dictionary whose keys are new column names and whose values are functions specifying how to compute the values of the new columns.

parameter:

keep_columns: list, default=None

additional_columns: dict, {column: predicate function}, default=None

return: Table

limit(lim)

to select a limited number of records

parameter:

lim: int

return:

Table

where(predicate=function)

defines the condition to be met for the rows to be returned

parameter:

predicate: a predicate function, default=lambda row: True

return:

Table

group_by(group_by_columns, aggregates, having=None)

group together rows with identical values in specified columns and produces aggregate values

parameter:

group_by_columns: list

aggregates: dict, {col: predicate function}

having: a predicate function, default=None

return:

Table

order_by(order)

sorts data returned by a predicate function

parameter:

order: a predicate function

return:

Table

join(other_table, left_join=False)

join two tables

parameter:

other_table: Table

left_join: boolean, default=False

return:

Table

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published