Skip to main content

SQython

A wrapper for SQL and python.

Checkout functions.MD for a list of the available use cases so far!

requirments

  • psycopg2
  • os (comes with python install)
  • numpy
  • io / StringIO (comes with python install)
  • pandas

This was made to create an easier access to SQL through python

instalation

NOTE TO MAKE SURE THE SQ IS CAPITALIZED WHEN INSTALLING AND IMPORTING !!!!!!!!!!!!!!!

pip install SQython

example use cases


import SQython as sq

# creating a connection to my DB and creating a new database

conn = sq.create_connection("postgres", "postgres", "3301", 'localhost', 5432)
sq.execute_query(conn,sq.create_database('maxtest'))

# after creating we need to connect to our new database

conn = sq.create_connection("maxtest", "postgres", "3301", 'localhost', 5432)


# creating a table based on column names and datatypes to each of their respective columns

sq.execute_query(conn,sq.make_table('testtable',['test1','test2','test3'],['serial','char(50)','char(50)'],'test1'))


# sample DataFrame that we will insert

data = {'test1':[1,2,3],
       'test2':['max','luke','aids'],
       'test3':['a','B','c']}
data = pd.DataFrame(data)

# pushing the data to DB
sq.execute_many(conn,data,'testtable')


# example of deleting new table

sq.execute_query(conn,sq.delete_table('testtable'))

# if we want to delete the current database we must connect to a different one before deletion

conn = sq.create_connection("postgres", "postgres", "3301", 'localhost', 5432)
sq.execute_query(conn,sq.delete_database('maxtest'))


# example of altering a column name
sq.execute_query(conn,sq.alter_column_name(testtable,'test2','names'))

# example of changing an existing columns datatype
# changing column 'names' to varchar
sq.execute_query(conn,sq.alter_datatype(testtable,'names','VARCHAR'))

# to write your own query!

query = 'select * from table'

sq.execute_query(conn,query)

# Currently working on a more efficient and easy querying method

FREE SOFTWARE HELL YEAH

Release files for SQython 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for SQython 0.0.5
File Size Uploaded
SQython-0.0.5.tar.gz 3.7 kB Details

Release files / SQython-0.0.5.tar.gz

Download URL SQython-0.0.5.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ea00fc288c445bf4af070c63e6ae0eb12c2ccb2d0402db0815ef68b62def338e
BLAKE2b-256 checksum
How to use checksums
bfdeb6c619bd6a7ed18224089e3f2b937424e4248ebbd8c0a63f8123a8272bb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.9

Release history Release notifications | RSS feed

This release

0.0.5 This release

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page