Skip to content

Instantly share code, notes, and snippets.

View mushonnip's full-sized avatar
🇮🇩
Working from home

Abu Mushonnip mushonnip

🇮🇩
Working from home
View GitHub Profile
@mushonnip
mushonnip / models.py
Last active December 5, 2023 22:54
Django model to generate unique id/ booking id/ transaction id
import uuid
class Booking(models.Model):
booking_no = models.CharField(primary_key=True, default=uuid.uuid4().hex[:5].upper(), max_length=50, editable=False)
def __str__(self):
return str(self.booking_no)
@mushonnip
mushonnip / connection.py
Created October 3, 2018 09:45 — forked from adnanfajr/connection.py
Simple Python CRUD with MySQL
#!/usr/bin/python
import MySQLdb as mdb
import sys
try:
con = mdb.connect('localhost', 'USERNAME MYSQL', 'PASSWORD MYSQL', 'NAMA DATABASE');
cur = con.cursor()
cur.execute("SELECT VERSION()")
ver = cur.fetchone()