Skip to main content

SQL but worse

Project description

# badsql This is a file-based version of SQL.

Pass the headers as the parameter to db()

`python mydb = db(['id', 'name', 'age']) `

Use .insert(pos, row) to add to the table

`python mydb.insert(1, [0, 'Bob', 11]) mydb.insert(2, [1, 'Sam', 9]) mydb.insert(3, [2, 'Will', 10]) `

Use .display() to show the table

`python print('Full table:\n') mydb.display() print('\n') `

Use .select(query) to select specific rows

`python print('Where age >= 10:\n') mydb.select('age >= 10').display() print('\n') `

Any Python-compilable code can be used

`python print('Where len(name) != 4:\n') mydb.select('len(name) != 4').display() print('\n') `

The .select() method returns a db object

To save the table use .save(filename)

`python mydb.save('table') `

To load in a table from a file use load(filename)

`python db2 = load('table') `

This returns a db object

`python print('Loaded from table.csv:\n') db2.display() `

Note:

for .save() and load(), ‘.csv’ is appended at the end of the filename in all cases.

[View on Github](https://github.com/nayakrujul/badsql)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

badsql-1.1.tar.gz (2.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page