Skip to content

Instantly share code, notes, and snippets.

View shivanshs9's full-sized avatar
🔥
Unlimited Code Works! ⚔️

Shivansh Saini shivanshs9

🔥
Unlimited Code Works! ⚔️
View GitHub Profile
@shivanshs9
shivanshs9 / rename-database.sql
Last active December 17, 2024 07:43
Rename MySQL Database
DROP PROCEDURE IF EXISTS moveTables;
DROP PROCEDURE IF EXISTS renameDatabase;
DELIMITER $$
CREATE PROCEDURE moveTables(_schemaName varchar(100), _newSchemaName varchar(100))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE table_name VARCHAR(64);
DECLARE table_cursor CURSOR FOR SELECT information_schema.tables.table_name FROM information_schema.tables
WHERE information_schema.tables.table_schema = _schemaName;

Keybase proof

I hereby claim:

  • I am shivanshs9 on github.
  • I am shivanshs9 (https://keybase.io/shivanshs9) on keybase.
  • I have a public key whose fingerprint is AB5F BF93 4643 CDEF C77F 7686 4A92 F697 E2C6 C0FC

To claim this, I am signing this object:

@shivanshs9
shivanshs9 / mixins.py
Created December 8, 2018 08:41
Mixin for Django Rest Framework View/Viewsets to use different response data/serializers without unnecessary hacks.
class UnsafeResponseSerializerMixin(object):
"""
Apply this mixin to any view or viewset to automatically use a different response
serializer on POST, PUT or PATCH requests.
Override 'get_response_data' method to return back the desired data, or
'get_response' method to also provide additional changs to the returned Response.
"""
def get_response_data(self, request):