This repository has been archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
__init__.py
67 lines (55 loc) · 1.86 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Goal : To create a working personal expense management system using MySQL and Python
# See README.txt for more project details.
# from tkinter import *
import mysql.connector as mysqlconnect
dbcredentials = {'host': 'localhost',
'password': 'bIgnInja349', 'user': 'root'}
conn = mysqlconnect.connect(**dbcredentials)
'''
TODO: Create the database and required tables if they don't exist. This'll be required for systems other than my local one. (Update -> Done)
'''
db_connection_cursor = conn.cursor()
def start_connection():
# <----------------- Database Creation ----------------------> #
db_connection_cursor.execute('CREATE DATABASE IF NOT EXISTS xpnsit;')
db_connection_cursor.execute('USE xpnsit')
# <----------------- Create Transactions Table ----------------> #
db_connection_cursor.execute(
"""CREATE TABLE IF NOT EXISTS transactions(
trans_id int(11) PRIMARY KEY AUTO_INCREMENT,
user_id int(5) NOT NULL,
username varchar(35),
particulars varchar(512),
exp_type set('CR','DR'),
amount double,
exp_date date
);""")
# <----------------- Create Users Table ----------------> #
db_connection_cursor.execute(
"""CREATE TABLE IF NOT EXISTS users(
user_id int(5) PRIMARY KEY AUTO_INCREMENT,
username varchar(35),
passwd varchar(40),
email_id varchar(45),
first_name tinytext,
last_name tinytext
);""")
# <------------------- OLD SYSTEM OF LOGIN (NOT USED) ----------------------> #
# import random
# import getpass
# import re
# import login
# import sys
# import stdiomask
# from tkinter import ttk
# import tkinter
# maindb = mysql.connector.connect(
# host = 'localhost',
# user = 'root',
# passwd = 'bIgnInja349',
# database = 'xpnsit'
# )
#
# cursor = maindb.cursor()
#
# get_em_credentials()