If you're a programmer, you know the difference between a beginner and a master is the ability to write succinct code that does a great deal with very little work. If you can do this, you can easily raise your productivity and the quality of your work by an order of magnitude. Much more importantly, you can have a lot more fun writing code. Read on to learn how.
This morning is rich for troubles
Some PHP script was to act with MySQL database, but it failed
with: “Warning: mysql_connect(): Client does not
support authentication protocol requested by server; consider
upgrading MySQL … Client does not support authentication protocol
requested by server; consider upgrading MySQL client“.
I’ve digged a bit and solution was very simple -
SET PASSWORD FOR user@localhost =
OLD_PASSWORD(?newpassword?);
This updates password to use old authentication protocol.
The final release of python 2.5 is out! The list of what’s new is pretty impressive, but I’m especially happy to have the new “with” statement. Ruby has block methods, or closures, which can be used for doing very clean setup/cleanup. While full-blown Anonymous block statements were rejected from Python, the new “with” statement handles the part I care about: making it easier to write code that works correctly in the case of failures.
The 3 typical use cases are a file that needs to be closed, a lock that needs to be released, and and a database transaction that needs to be either committed or rolled back. The database case is the …
[Read more]
The PyBots project (http://pybots.org/) is a way for people to run
tests for python applications using Python binaries built from
the very latest source code from the Python subversion
repository. The idea is brilliant, and has application far beyond
the Python project.
As Grig Gheorghiu previously announced on his blog, I’ve set up
a buildslave testing MySQLdb, the python connector for MySQL.
I’ll probably try to set up tests for SQLAlchemy next.
You can see the builder status page here, my builder is named
‘amd64 Ubuntu Dapper trunk’.
Instructions for how to set up a buildslave are on pybots.org,
and you can see the buildscripts along …
This is my second article on how to build a role-based access control system in SQL. In the first article I gave a high-level overview of access control systems in general, especially in the web-application context, and talked about how some are implemented. I introduced the problems I designed my system to solve, and gave a roadmap for where this series of articles will end. I finished that article with a sketch of some basics to provide row-level read, write, and delete access control.
This article picks up where I left off. I want to revisit some things I swept under the rug in the first article, because I didn't want to throw all the complexity in at once. I'll explain my current system's full functionality, which includes roles, type checking, table-level and set-level privileges, and more. I will show you the design in great detail, and give working examples and ready-to-run SQL queries. I'll also explore ideas for extending or …
[Read more]The posts I've been reading and writing recently have reminded me how Object-Relational Mapping (ORM) systems make it fun and convenient to interact with databases. For some of the reasons they're a developer's favorite, they can be a database administrator's nightmare (think surrogate keys). But designing tables with a consistent set of columns has its benefits. Just because the columns are meta-data that have no intrinsic meaning doesn't mean they have no value. In this series of articles I'll show you several ways to use such "meaningless" meta-data to enable powerful, efficient application-level role-based access control (RBAC) in the database, with a focus on web applications, though you could do this for any application.
The systems I've built are complex, so I'll split this into at least two articles. This first article will discuss other privilege systems I've seen in web applications, including …
[Read more]Quite a few people have chimed in on a recent discussion about PHP, MySQL, database abstraction layers, and performance. I think enough viewpoints have been covered that I don't need to comment, but one question I don't see answered is "what are the qualities of a good SQL abstraction layer?" I think it's a very interesting -- and complicated -- question. As it turns out, the term has several meanings, and I think it's important to understand them. In this article I explain one way to categorize different types of database abstraction layers, the goals for each, and some useful success criteria.
"My code is all in version control," Joe said proudly. "Everything is versioned. I'll never lose any work." But then he lost some "other" code he didn't realize was critical. This article is about how to find and safeguard all the hidden code you don't know your business relies on.
I've seen a lot of SQL code that uses an IN
clause
as a place to put a variable number of parameters, allowing the
query to be more flexible. There are several downsides to this
technique. This article discusses those downsides and explains
how to avoid them.
Groggy mentions trying to draw sequence diagrams with pic. I recommend using Spinellis excellent UMLGraph toolset that he developed while writing Code Reading. That book was wonderfully inspiring to me, and helped cement my desire to work on open source software.
From what I remember, the sequence diagram stuff was a clever set of pic macros, so that you could just describe a sequence diagram and then generate the picture. I love having pictures to use during a discussion because they help avoid confusion, but I absolutely hate drawing pictures or using drawing tools - I prefer to keep the diagrams in plain-text, source code, in a revision control system. Using pic for the sequence diagrams fits the bill perfectly. Code is …
[Read more]