Skip to content

Commit

Permalink
sqlite bug
Browse files Browse the repository at this point in the history
  • Loading branch information
krishvsoni committed Feb 13, 2024
1 parent 2cb7c1f commit 04fe009
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 27 deletions.
17 changes: 10 additions & 7 deletions build/lib/flask_wiz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@ def cli():

@cli.command()
def new():
# Prompt user for project name
name = click.prompt('Enter project name')

# Prompt user for database system
db_options = ['mongodb', 'sqlite', 'mysql', 'postgresql']
db = click.prompt('Select database system', type=click.Choice(db_options))

# Additional setup code for the new project (e.g., creating files, folders, etc.)
os.makedirs(name)
os.chdir(name)

# Create directories for templates and static files
os.makedirs('templates')
os.makedirs('static')

Expand All @@ -37,14 +33,15 @@ def new():
gitignore_file.write("venv/\n")
gitignore_file.write("__pycache__/\n")
gitignore_file.write(".vscode/\n")
# Add more entries as needed

with open('.env', 'w') as env_file:
env_file.write("# Default .env file for Flask project\n")
# Add default environment variables if needed

with open('app.py', 'w') as app_file:
db_module = None

if db == 'mongodb':
db_module = 'pymongo'
app_file.write(
"""from flask import Flask
from pymongo import MongoClient
Expand All @@ -61,6 +58,7 @@ def index():
app.run()
""")
elif db == 'sqlite':
db_module = 'sqlite3'
app_file.write(
"""from flask import Flask
import sqlite3
Expand All @@ -76,6 +74,7 @@ def index():
app.run()
""")
elif db == 'mysql':
db_module = 'pymysql'
app_file.write(
"""from flask import Flask
import pymysql
Expand All @@ -91,6 +90,7 @@ def index():
app.run()
""")
elif db == 'postgresql':
db_module = 'psycopg2'
app_file.write(
"""from flask import Flask
import psycopg2
Expand All @@ -106,7 +106,10 @@ def index():
app.run()
""")

if db_module:
os.system(f"pip install {db_module}") # Install the required database module

click.echo(f'New Flask project "{name}" created successfully with {db} database!')

if __name__ == '__main__':
cli()
cli()
Binary file removed dist/flask-wiz-1.6.3.tar.gz
Binary file not shown.
Binary file added dist/flask-wiz-1.9.1.tar.gz
Binary file not shown.
Binary file added dist/flask-wiz-1.9.tar.gz
Binary file not shown.
Binary file removed dist/flask_wiz-1.6.3-py3-none-any.whl
Binary file not shown.
Binary file added dist/flask_wiz-1.9-py3-none-any.whl
Binary file not shown.
Binary file added dist/flask_wiz-1.9.1-py3-none-any.whl
Binary file not shown.
2 changes: 1 addition & 1 deletion flask_wiz.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: flask-wiz
Version: 1.6.3
Version: 1.9.1
Author: Krish Soni
Description-Content-Type: text/markdown

Expand Down
4 changes: 0 additions & 4 deletions flask_wiz.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
flask
click
Flask
sqlite
mysql-connector-python
psycopg2
pymongo
Binary file modified flask_wiz/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added flask_wiz/__pycache__/cli.cpython-311.pyc
Binary file not shown.
17 changes: 10 additions & 7 deletions flask_wiz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@ def cli():

@cli.command()
def new():
# Prompt user for project name
name = click.prompt('Enter project name')

# Prompt user for database system
db_options = ['mongodb', 'sqlite', 'mysql', 'postgresql']
db = click.prompt('Select database system', type=click.Choice(db_options))

# Additional setup code for the new project (e.g., creating files, folders, etc.)
os.makedirs(name)
os.chdir(name)

# Create directories for templates and static files
os.makedirs('templates')
os.makedirs('static')

Expand All @@ -37,14 +33,15 @@ def new():
gitignore_file.write("venv/\n")
gitignore_file.write("__pycache__/\n")
gitignore_file.write(".vscode/\n")
# Add more entries as needed

with open('.env', 'w') as env_file:
env_file.write("# Default .env file for Flask project\n")
# Add default environment variables if needed

with open('app.py', 'w') as app_file:
db_module = None

if db == 'mongodb':
db_module = 'pymongo'
app_file.write(
"""from flask import Flask
from pymongo import MongoClient
Expand All @@ -61,6 +58,7 @@ def index():
app.run()
""")
elif db == 'sqlite':
db_module = 'sqlite3'
app_file.write(
"""from flask import Flask
import sqlite3
Expand All @@ -76,6 +74,7 @@ def index():
app.run()
""")
elif db == 'mysql':
db_module = 'pymysql'
app_file.write(
"""from flask import Flask
import pymysql
Expand All @@ -91,6 +90,7 @@ def index():
app.run()
""")
elif db == 'postgresql':
db_module = 'psycopg2'
app_file.write(
"""from flask import Flask
import psycopg2
Expand All @@ -106,7 +106,10 @@ def index():
app.run()
""")

if db_module:
os.system(f"pip install {db_module}") # Install the required database module

click.echo(f'New Flask project "{name}" created successfully with {db} database!')

if __name__ == '__main__':
cli()
cli()
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
'flask',
'click',
'Flask',
'sqlite',
'mysql-connector-python',
'psycopg2',
'pymongo',
# 'sqlite3',
# 'mysql-connector-python',
# 'psycopg2',
# 'pymongo',
]

setup(
name='flask-wiz',
version='1.6.3',
version='1.9.1',
author='Krish Soni',
packages=find_packages(),
include_package_data=True,
Expand All @@ -27,4 +27,4 @@
},
long_description=long_description,
long_description_content_type="text/markdown",
)
)
4 changes: 2 additions & 2 deletions wiz.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def index():
app.run()
""")
elif db == 'sqlite':
db_module = 'sqlite3'
#db_module = 'sqlite3'
app_file.write(
"""from flask import Flask
import sqlite3
Expand Down Expand Up @@ -112,4 +112,4 @@ def index():
click.echo(f'New Flask project "{name}" created successfully with {db} database!')

if __name__ == '__main__':
cli()
cli()

0 comments on commit 04fe009

Please sign in to comment.