Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Saturday, January 22, 2011

Export Create Table Script in mySQL

SHOW CREATE TABLE TableName;

Sunday, September 12, 2010

MySQLdb - 1153, 'Got a packet bigger than 'max_allowed_packet' bytes'

the technology

- mySQL Server 5.?
- python 2.6
- MySQLdb 2.3.1?
- Windows 7

the scenario

1. import MySQLdb
2. create a connection to the db:
> connxn = MySQLdb.connect(params_dict)
3. loop, re-using the connection, each time inserting say 250 records in one query
> cursor = connxn.cursor()
> cursor.execute(multi_record_insert_statement)
> cursor.close()
> connxn.commit()

problem is, i was getting the following errors:

- 1153, 'Got a packet bigger than 'max_allowed_packet' bytes'
then, when i tried to create a new connection, i was getting
- 2006, 'MySQL server has gone away'

Saturday, September 19, 2009

mySQL - Python

Official mySQL Site on Integration

MySQLdb is an interface for connecting to a MySQL database server from Python. It implements the Python Database API v2.0, and is built on top of the MySQL C API.

Writing MySQL Scripts with Python DB-API
SourceForge mySQL-Python Home
PEP 249 : Python Database API Specification v2.0

DOWNLOAD
MySQL for Python [SourceForge]

Installing & Configuring MySQL

excellent BASIC MYSQL CONFIGURATION

(typical) LOCATION OF mySQL CONFIG FILE [=my.cnf]
= /etc/mysql/my.cnf

LOG ON TO MYSQL CONSOLE
> mysql - u user -p

drop database syntax

How to change the mysql database location

LIST DATABASES
> mysqlshow -u root -p

CREATE DATABASE
1
2
3

SHUTDOWN SERVER
mysqladmin -u root -p shutdown

---

Information Schema Tables [official mysql ref]

The schema 'information_schema' contains the meta-data for the db server

TO QUERY ALL TABLES CONTAINED IN DB test
> select *
> from information_schema.tables
> where table_schema = 'test';

Saturday, June 20, 2009

Setting up a mySQL DataBase on uBuntu

http://www.debuntu.org/how-to-create-a-mysql-database-and-set-privileges-to-a-user

'import MySQLdb' failed

http://davidmichaelthompson.com/?p=12

duh, need to install package 'python-mysqldb', 'A Python interface to mySQL'.