Azizul Hakim
commited on
app.py
Browse files
app.py
CHANGED
|
@@ -117,6 +117,7 @@ def bulk_import_data(db_name, df):
|
|
| 117 |
conn.close()
|
| 118 |
|
| 119 |
def main():
|
|
|
|
| 120 |
st.title("🗃️ Database Operations Tool")
|
| 121 |
|
| 122 |
# Sidebar for database operations
|
|
@@ -127,18 +128,25 @@ def main():
|
|
| 127 |
with st.expander("Create New Database", expanded=True):
|
| 128 |
new_db_name = st.text_input("Database Name")
|
| 129 |
columns_input = st.text_input("Column Names (comma-separated)")
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
|
| 134 |
if st.button("Create Database"):
|
| 135 |
-
if new_db_name and columns_input and
|
| 136 |
try:
|
| 137 |
-
columns = [col.strip() for col in columns_input.split(",")]
|
| 138 |
-
if len(columns) != len(column_types):
|
| 139 |
-
st.error("❌ Number of columns and types must match!")
|
| 140 |
-
return
|
| 141 |
-
|
| 142 |
conn = init_db()
|
| 143 |
c = conn.cursor()
|
| 144 |
c.execute("INSERT INTO database_list VALUES (?, ?)",
|
|
@@ -271,4 +279,4 @@ def main():
|
|
| 271 |
st.info("👋 Welcome! Start by creating a new database using the sidebar.")
|
| 272 |
|
| 273 |
if __name__ == "__main__":
|
| 274 |
-
main()
|
|
|
|
| 117 |
conn.close()
|
| 118 |
|
| 119 |
def main():
|
| 120 |
+
|
| 121 |
st.title("🗃️ Database Operations Tool")
|
| 122 |
|
| 123 |
# Sidebar for database operations
|
|
|
|
| 128 |
with st.expander("Create New Database", expanded=True):
|
| 129 |
new_db_name = st.text_input("Database Name")
|
| 130 |
columns_input = st.text_input("Column Names (comma-separated)")
|
| 131 |
+
|
| 132 |
+
# Modified column type selection
|
| 133 |
+
if columns_input:
|
| 134 |
+
columns = [col.strip() for col in columns_input.split(",")]
|
| 135 |
+
column_types = []
|
| 136 |
+
|
| 137 |
+
# Create a select box for each column
|
| 138 |
+
st.write("Select type for each column:")
|
| 139 |
+
for col in columns:
|
| 140 |
+
col_type = st.selectbox(
|
| 141 |
+
f"Type for {col}",
|
| 142 |
+
options=["TEXT", "INTEGER", "REAL", "BLOB", "DATE"],
|
| 143 |
+
key=f"type_{col}" # Unique key for each selectbox
|
| 144 |
+
)
|
| 145 |
+
column_types.append(col_type)
|
| 146 |
|
| 147 |
if st.button("Create Database"):
|
| 148 |
+
if new_db_name and columns_input and len(columns) > 0:
|
| 149 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
conn = init_db()
|
| 151 |
c = conn.cursor()
|
| 152 |
c.execute("INSERT INTO database_list VALUES (?, ?)",
|
|
|
|
| 279 |
st.info("👋 Welcome! Start by creating a new database using the sidebar.")
|
| 280 |
|
| 281 |
if __name__ == "__main__":
|
| 282 |
+
main()
|