I am trying to write setup.py
for very first time. Installation is working fine but could not create database and tables through script.
Here is my file:
import os
import sys
from distutils.sysconfig import get_python_lib
from setuptools import find_packages, setup
# Dynamically calculate the version based on django.VERSION.
version = __import__('flask').__version__
setup(
name='myapp_manager',
version='1.0.0',
description='myapp manger',
long_description=('myapp manger description'),
url='https://github.com/XXXXXXXXXX.git',
packages=find_packages(exclude=['tests*']),
install_requires=["Flask==0.10.1",
"Flask-SQLAlchemy==1.0",
"Jinja2==2.8",
...
],
include_package_data=True,
entry_points = {
'console_scripts': [
'create_db = myapp_manager.scripts.create_db:main',
]
},
package_data={
'static': 'static/*',
'templates': 'templates/*'},
classifiers=[
"Private :: Do Not Upload"
],
)
and here is my project dir structure:
myapp_manager
|-- app
| |-- api_calls.py
| |-- api_templates.py
| |-- __init__.py
| |-- logger.py
| `-- loginapp
| |-- controller.py
| `-- __init__.py
|-- run.py
|-- scripts
| |-- create_db.py
| `-- __init__.py
|-- settings.py
`-- setup.py
and here is the create_db.py (This runs without error when run standalone)
import MySQLdb
def main():
db1 = MySQLdb.connect(host="localhost", user="root",passwd="passwordstr")
cursor = db1.cursor()
sql = 'CREATE DATABASE myappdb;'
cursor.execute(sql)
if __name__ == '__main__':
main()
I'm not sure if it is going in create_db.py, but the when I run I could see the following line : Installing create_db script to /usr/local/bin
And in Mysql :
mysql>show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| xapp_db |
| mysql |
| performance_schema |
+--------------------+