Django migrating from sqlite to MySQL. Fixture error - mysql

I'm trying to export my SQLite data and then import into MySQL (after making the appropriate changes to the settings.py file). Here is the error I see when trying to import the data:
python manage.py loaddata < datadump.json
CommandError: No database fixture specified. Please provide the path of at least one fixture in the command line.
Any ideas on what the problem could be?

Remove the '<'
python manage.py loaddata datadump.json

Related

Failing to import SQLAlchemy and Pymysql into AWS Glue Python Shell script

I have a Python script which imported 3 libraries:
import pymysql
import pandas as pd
from sqlalchemy import create_engine
I'm planning to run Python Shell on AWS Glue. Following this and this doc pages, I created a setup.py:
from setuptools import setup
setup(name="pylibmodule",
version="0.1",
packages=[],
install_requires=['sqlalchemy==1.3.9','pandas==0.25.3','pymysql==0.9.3']
)
I ran python setup.py bdist_wheel, put the resulting pylibmodule-0.1-py3-none-any.whl file into an S3 bucket, and then specified the bucket location in the Glue Job setting. When I ran the job script, it produced an error.
After an investigation, I found that I have sucessfully imported the pandas module, but failed to import sqlalchemy and pymysql.
ModuleNotFoundError: No module named 'sqlalchemy'
ModuleNotFoundError: No module named 'pymysql'
What am I doing wrong?
I ran the job again this morning without changing anything in the setting and the script. It suddenly works. I think the error I received last night was due to some cache residue on Glue's end.

Error in importing MySQL connector in Python 3.5

I am getting ImportError: No module named 'mysql' while I do the following...
>>> import mysql.connector
MySQL is installed and am on Python 3.5. I can't figure out. The above command is running fine in Python 2.7.
Unfortunately there is no mysql-connector available for python3.5.
So, you can use pymysql module which is a replacement for mysql-connector package
pip install pymysql
import pymysql
Connection = pymysql.connect(host='hostname', user='username', password='password',
db='database',charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor )
ExecuteQuery(Connection)
Connection.close()
For me (OS X 10.11.4, Python 3.5.1), the mysql-connector-package installed itself (by default) into Python 2.7 that was also on my system. I copied the mysql package directory from:
/Library/Python/2.7/site-packages/mysql to /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mysql. Everything works. According to http://dev.mysql.com/doc/connector-python/en/connector-python-versions.html the connector package supports Python 3.3+.
Your specific installation path for the module may be different, but you can easily check this from the REPL using the sys.path:
https://leemendelowitz.github.io/blog/how-does-python-find-packages.html
As we need to be connecting MySQl with Python, the Python command assumes that the connector is enabled. So we need to follow the steps below:
open MySQL Installer;
go to "Custom settings";
go to "Connectors";
choose the connector\Python and version based on the one you are using;
add it;
use import mysql.connector.
It should run, in my case it did!
From Can't run MySql Utilities:
MYSQL Utilities assumes that the MySQL Connector for Python has been installed. If you install it (http://dev.mysql.com/downloads/connector/python/), MySQL Utilities should run OK.
I think this link may help you to solve your problem.

Flask-migrate on openshift

I am using flask. I installed Flask-migrate and have been using it to migrate my postgresql db. It works fine on my local box. However, when I run it on openshift I get an error
"File "/opt/rh/python27/root/usr/lib64/python2.7/ConfigParser.py", line 396, in set
raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'alembic'
"
Anyone know what this is or how to fix it?
It probably means that Flask Migrate is unable to find alembic configuration. Flask Migrate depends on Alembic to generate db revisions.
By default, Flask Migrate searches for configuration(and db version scripts) in migrations directory. If your configuration is present in different folder, you can specify it using -d <dir>
I think this is a bug with LD_Library_path that should be fixed in this sprint. Should be rolling out to production in a week or two

How to use django's manage.py sql* commands with mysql

How are the sql* commands meant to be used? They just output sql, so is there an elegant way to pass it to mysql? ./manage.py sqlindexes [app] gives me the mysql code - do I just note it down and then type it in? (edit: erm...copy and paste for others. heh.)
Pardon my ignorance, and please let me know if there's a completely different but better way of using it.
Pipe it to the dbshell command like so:
python manage.py sqlindexes my_app | python manage.py dbshell

manage.py runserver not working

I am new to django and python in general, so pardon me for any simple mistakes I may be doing. I am trying to setup my first django project on my local windows vista machine. I have created the project successfully with no problems. The issue I am coming across is when my settings.py has values for my database keys, the manage.py runserver command is failing. If I have values in settings before I run the command, as soon as I run it I get errors. If I have already run the command and the server is running, as soon as I edit the settings file with values, the errors show up in my still open command prompt. The inner most exception seems to "Error loading MySQLdb module: No module named MYSQLdb". If I leave the settings.py blank, the command executes with no problems.
Any advice would be greatly appreciated!
Thanks
You don't have mysql-python module installed, thats why you getting that error.
You could find that module at
http://pypi.python.org/pypi/MySQL-python/
Install the MySQLdb module, or the oursql module along with the django-oursql connector.